CAPSTONE PROJECT - THE BATTLE OF NEIGHBORHOODS

VISITING LONDON CITY

Applied Data Science Capstone by IBM/Coursera. Author: Jorge Alvarez

Table of contents

1. Introduction

London is the capital and largest city of England and the United Kingdom. Its estimated mid-2018 municipal population (corresponding to Greater London) was roughly 9 million, which made it the third-most populous city in Europe. London accounts for 13.4% of the U.K. population. Greater London Built-up Area is the fourth-most populous in Europe with 9,787,426 inhabitants at the 2011 census.

London has been one of the world's top tourism cities for many years, and a key gateway for domestic and international visitors. The total number of visitors in London, including domestic tourists, is estimated at 12 million per year.

As a result, tourism is the second most important sector for the economy of the city after financial services, contributing 12% to its GDP. Tourism, therefore, plays a vital role for London. The sector employs 700,000 people and contributes £36 billion a year to the economy. Tourism also helps to strengthen London's reputation as an open and welcoming global city.

2. Business Problem

London is a world tourist destination with many visitors each year. The information available concerning tourism in London can be overwhelming and considering trips made to London for holiday purposes lasted 4.8 nights on average in 2019, according to Statista, a good planning is necessary to make the most of the holidays, avoiding downtimes. London has full potential to become the best city to visit in Europe but it still has challenges for visitors such as not using public transport wisely, waiting in long queues as a result of a poor planning and failing to research available attractions.

This project will analyse the venues available for people visiting London in order to look for the best recreational activities and locations in the variety of districts in London city. The venues will be analyzed first as a whole and structured afterwards by district for a better comprehension as well.

This project will be interesting to visitors and expats who are considering visiting and relocating to London as they will be able to identify the most attractive locations in London and explore its districts and common venues around each district.

3. Data

This section describes the data that will be used to solve the problem concerning the tourism and visits to London city.

3.1. Libraries

The libraries installed and imported to be used in this project are summarized below:

  • Numpy: Library to handle data in a vectorized manner. It is used to create cluster labels during the clustering stage.

  • Pandas: Library for data analysis. In this project is used to build DataFrames containing Postal Codes, districts, venues, latitudes, longitudes.

  • Requests: Library to handle requests. It is used to scrape the list of Postal Codes in London city from Milesfaster website (please, refer to sources section below).

  • BeautifulSoup: Library used for pulling data out of html and XML files. It is necessary to scrape information from web pages.

  • Geopy: Library used to convert an address into latitude and latitude values. It is used to add the latitudes and longitudes to the districts scraped.

  • Json: Library to handle JSON files. In this project is used to make the GET request during the neighborhood exploration stage.

  • folium: Library used to create maps. It is used to create maps in London city, containing all districts previously scraped.

  • matplotlib.pyplot: Library used to plot bar plots.

  • Matplotlib.cm and Matplotlib.colors: Library used to plot a range of colors in London city maps.

  • WordCloud: Library used to plot a world cloud containing the most common venues in each district.

  • k-means: Library used to apply k-means clustering algorithm used to cluster districts in London city.

3.2. Data Acquisition

The data acquired for this project contains the following columns:

  • Postal Code: Contains the postal codes of London city that have the following coding. C: Central, N: North, E: East, W: West, SE: South East, SW: South West, NE: North East, NW: North West.

  • District: London city districts within a Postal Code.

  • Postal Code Latitude: Latitude of a given Postal Code in London city.

  • Postal Code Longitude: Longitude of a given Postal Code in London city.

  • Venue: Venue names within a district in London city.

  • Venue Latitude: Latitude of a given venue in London city.

  • Venue Longitude: Longitude of a given venue in London city.

  • Venue Category: Category of a given venue (such as bakery, coffee shop, movie theater, etc.)

  • Most common venue: The most common venue within a district ranging from 1st to 10th.

3.3. Data sources

For this project the following data and sources will be used:

  • Milesfaster website This is a London Hotels specialist website which contains the postal codes and districts of London city. The postal codes and district data of London city will be scraped from Milesfaster using the beautiful soup library of Python, however, it requires an additional data cleaning step to reorganize and label columns. Milesfaster url is the following: https://www.milesfaster.co.uk/london-postcodes-list.htm
  • ArcGIS Geocoding is the computational process of transforming a physical address description to a location on the Earth's surface (spatial representation in numerical coordinates). ArcGIS will be used to turn addresses into coordinates, finding addresses interactively and geocoding a table of addresses.
  • Foursquare API to get the most common venues of given district in London city. Foursquare API has one of the largest database of 105+ million places and is used by over 1250,000 developers. It provides different data information of venues among districts. Foursquare data contains venues, longitude, latitude and postal codes. The information obtained per venue as follows: district, district latitude, district longitude, venue name, venue latitude, venue longitude, venue category. This will be used in the methodology section.

Installing and importing libraries

Before exploring the data, the necessary libraries will be installed and imported.

In [1]:
import numpy as np # library to handle data in a vectorized manner

import pandas as pd # library for data analysis
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)

import json # library to handle JSON files

!conda install -c conda-forge geopy --yes
from geopy.geocoders import Nominatim # convert an address into latitude and longitude values

# install and import geocoder
!pip -q install geocoder
import geocoder

import requests # library to handle requests
from pandas.io.json import json_normalize # transform JSON file into a pandas DataFrame

!pip install beautifulsoup4
from bs4 import BeautifulSoup # import BeautifulSoup library

# Matplotlib and associated plotting modules
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors

# install wordcloud
!conda install -c conda-forge wordcloud==1.8.1 --yes

# import wordcloud and its set of stopwords
from wordcloud import WordCloud, STOPWORDS

# import k-means from clustering stage
from sklearn.cluster import KMeans

!conda install -c conda-forge folium=0.5.0 --yes
import folium # map rendering library

print('Libraries installed and imported.')
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Requirement already satisfied: beautifulsoup4 in c:\users\jorge\anaconda3\lib\site-packages (4.8.2)
Requirement already satisfied: soupsieve>=1.2 in c:\users\jorge\anaconda3\lib\site-packages (from beautifulsoup4) (1.9.5)
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Libraries installed and imported.

3.4. Scraping the list of postal codes in London city dataset from Milesfaster website

The raw data is extracted from Milesfaster website, then processed parsing the html document and finally converted into a DataFrame.

In [2]:
# reading the Milesfaster website content of the server's response
url='https://www.milesfaster.co.uk/london-postcodes-list.htm'
response = requests.get(url)

# parsing the html document from the Milesfaster website using BeautifulSoup library
data = response.text
London_data = BeautifulSoup(data, 'html.parser')
milesfaster_table = London_data.find('table')

# converting the Milesfaster html table into a DataFrame using Pandas library
df_PCLondon = pd.read_html(str(milesfaster_table))[0]
In [3]:
# displaying the first 10 results in the df_PCLondon DataFrame
df_PCLondon.head(10)
Out [3]:
0 1 2 3
0 E1 Whitechapel, Stepney, Mile End SE1 Waterloo, Bermondsey, Southwark, Borough
1 E1W Wapping SE2 Abbey Wood
2 E2 Bethnal Green, Shoreditch SE3 Blackheath, Westcombe Park
3 E3 Bow, Bromley-by-Bow SE4 Brockley, Crofton Park, Honor Oak Park
4 E4 Chingford, Highams Park SE5 Camberwell
5 E5 Clapton SE6 Catford, Hither Green, Bellingham
6 E6 East Ham SE7 Charlton
7 E7 Forest Gate, Upton Park SE8 Deptford
8 E8 Hackney, Dalston SE9 Eltham, Mottingham
9 E9 Hackney, Homerton SE10 Greenwich

As can be observed in the first 10 results of the DataFrame df_PCLondon, this DataFrame should be splitted because the postal codes are displayed in two columns simultaneously. The df_PCLondon DataFrame should be splitted into 2 separated DataFrames.

In [4]:
# This new DataFrame df1 gets the first 2 columns of df_PCLondon DataFrame
df1 = df_PCLondon[[0, 1]]

# displaying the first 10 results in the df1 DataFrame
df1.head(10)
Out [4]:
0 1
0 E1 Whitechapel, Stepney, Mile End
1 E1W Wapping
2 E2 Bethnal Green, Shoreditch
3 E3 Bow, Bromley-by-Bow
4 E4 Chingford, Highams Park
5 E5 Clapton
6 E6 East Ham
7 E7 Forest Gate, Upton Park
8 E8 Hackney, Dalston
9 E9 Hackney, Homerton
In [5]:
# This new DataFrame df2 gets the last 2 columns of df_PCLondon DataFrame
df2 = df_PCLondon[[2, 3]]

# displaying the first 10 results in the df2 DataFrame
df2.head(10)
Out [5]:
2 3
0 SE1 Waterloo, Bermondsey, Southwark, Borough
1 SE2 Abbey Wood
2 SE3 Blackheath, Westcombe Park
3 SE4 Brockley, Crofton Park, Honor Oak Park
4 SE5 Camberwell
5 SE6 Catford, Hither Green, Bellingham
6 SE7 Charlton
7 SE8 Deptford
8 SE9 Eltham, Mottingham
9 SE10 Greenwich

As may be seen in DataFrames df1 and df2, columns labels don't match. By renaming columns labels in DataFrame df2 with the same labels of DataFrame df1 both DataFrames can be merged in a single DataFrame.

In [6]:
# renaming columns labels in df2 DataFrame
df2 = df2.rename(columns={2: 0, 3: 1})

# displaying the first 10 results in the df2 DataFrame
df2.head(10)
Out [6]:
0 1
0 SE1 Waterloo, Bermondsey, Southwark, Borough
1 SE2 Abbey Wood
2 SE3 Blackheath, Westcombe Park
3 SE4 Brockley, Crofton Park, Honor Oak Park
4 SE5 Camberwell
5 SE6 Catford, Hither Green, Bellingham
6 SE7 Charlton
7 SE8 Deptford
8 SE9 Eltham, Mottingham
9 SE10 Greenwich

Now DataFrames df1 and df2 can be merged in a single DataFrame.

In [7]:
# This code merges DataFrames df1 and df2 in a single DataFrame df_PCLondon
df_PCLondon = df1.append(df2)

# printing the complete DataFrame df_PCLondon
print(df_PCLondon)
       0                                           1
0     E1              Whitechapel, Stepney, Mile End
1    E1W                                     Wapping
2     E2                   Bethnal Green, Shoreditch
3     E3                         Bow, Bromley-by-Bow
4     E4                     Chingford, Highams Park
5     E5                                     Clapton
6     E6                                    East Ham
7     E7                     Forest Gate, Upton Park
8     E8                            Hackney, Dalston
9     E9                           Hackney, Homerton
10   E10                                      Leyton
11   E11                                 Leytonstone
12   E12                                  Manor Park
13   E13                                    Plaistow
14   E14   Poplar, Millwall, Isle of Dogs, Docklands
15   E15                         Stratford, West Ham
16   E16     Canning Town, North Woolwich, Docklands
17   E17                                 Walthamstow
18   E18                              South Woodford
19   E20                                Olympic Park
20   NaN                                         NaN
21   WC1                       Bloomsbury, Grays Inn
22   WC2              Covent Garden, Holborn, Strand
23   NaN                                         NaN
24   EC1             Clerkenwell, Finsbury, Barbican
25   EC2                  Moorgate, Liverpool Street
26   EC3               Monument, Tower Hill, Aldgate
27   EC4                     Fleet Street, St. Pauls
28   NaN                                         NaN
29    N1             Islington, Barnsbury, Canonbury
30    N2                               East Finchley
31    N3                            Finchley Central
32    N4                  Finsbury Park, Manor House
33    N5                                    Highbury
34    N6                                    Highgate
35    N7                                    Holloway
36    N8                         Hornsey, Crouch End
37    N9                              Lower Edmonton
38   N10                                Muswell Hill
39   N11                Friern Barnet, New Southgate
40   N12               North Finchley, Woodside Park
41   N13                               Palmers Green
42   N14                                   Southgate
43   N15                               Seven Sisters
44   N16              Stoke Newington, Stamford Hill
45   N17                                   Tottenham
46   N18                              Upper Edmonton
47   N19                       Archway, Tufnell Park
48   N20                       Whetstone, Totteridge
49   N21                              Winchmore Hill
50   N22                Wood Green, Alexandra Palace
51   NaN                                         NaN
52   NW1                   Regents Park, Camden Town
53   NW2                        Cricklewood, Neasden
54   NW3                    Hampstead, Swiss Cottage
55   NW4                         Hendon, Brent Cross
56   NW5                                Kentish Town
57   NW6        West Hampstead, Kilburn, Queens Park
58   NW7                                   Mill Hill
59   NW8                               St Johns Wood
60   NW9                         Kinsbury, Colindale
61  NW10          Willesden, Harlesden, Kensal Green
62  NW11         Golders Green, Hampstead Gdn Suburb
63   NaN                                         NaN
0    SE1    Waterloo, Bermondsey, Southwark, Borough
1    SE2                                  Abbey Wood
2    SE3                  Blackheath, Westcombe Park
3    SE4      Brockley, Crofton Park, Honor Oak Park
4    SE5                                  Camberwell
5    SE6           Catford, Hither Green, Bellingham
6    SE7                                    Charlton
7    SE8                                    Deptford
8    SE9                          Eltham, Mottingham
9   SE10                                   Greenwich
10  SE11                                     Lambeth
11  SE12                             Lee, Grove Park
12  SE13                      Lewisham, Hither Green
13  SE14                   New Cross, New Cross Gate
14  SE15                            Peckham, Nunhead
15  SE16  Rotherhithe, South Bermonsey, Surrey Docks
16  SE17                 Walworth, Elephant & Castle
17  SE18                         Woolwich, Plumstead
18  SE19               Upper Norwood, Crystal Palace
19  SE20                              Penge, Anerley
20  SE21                                     Dulwich
21  SE22                                East Dulwich
22  SE23                                 Forest Hill
23  SE24                                  Herne Hill
24  SE25                               South Norwood
25  SE26                                    Sydenham
26  SE27                    West Norwood, Tulse Hill
27  SE28                                  Thamesmead
28   NaN                                         NaN
29   SW1             Westminster, Belgravia, Pimlico
30   SW2                     Brixton, Streatham Hill
31   SW3                           Chelsea, Brompton
32   SW4                                     Clapham
33   SW5                                 Earls Court
34   SW6                       Fulham, Parsons Green
35   SW7                            South Kensington
36   SW8                    South Lambeth, Nine Elms
37   SW9                          Stockwell, Brixton
38  SW10                   West Brompton, Worlds End
39  SW11                 Battersea, Clapham Junction
40  SW12                                      Balham
41  SW13                           Barnes, Castelnau
42  SW14                        Mortlake, East Sheen
43  SW15                          Putney, Roehampton
44  SW16                          Streatham, Norbury
45  SW17                                     Tooting
46  SW18                      Wandsworth, Earlsfield
47  SW19                           Wimbledon, Merton
48  SW20                South Wimbledon, Raynes Park
49   NaN                                         NaN
50    W1                   Mayfair, Marylebone, Soho
51    W2                       Bayswater, Paddington
52    W3                                       Acton
53    W4                                    Chiswick
54    W5                                      Ealing
55    W6                                 Hammersmith
56    W7                                     Hanwell
57    W8                                  Kensington
58    W9                  Maida Vale, Warwick Avenue
59   W10            Ladbroke Grove, North Kensington
60   W11                  Notting Hill, Holland Park
61   W12                              Shepherds Bush
62   W13                                 West Ealing
63   W14                             West Kensington

3.5. Data Cleaning

As can be noticed in the resulting df_PCLondon DataFrame the columns labels should be renamed to a more descriptive labels. There are NaN values in some rows that must be removed as well.

In [8]:
# renaming the columns names
df_PCLondon.columns = ['Postal Code', 'District']

# displaying the first 10 results in the df_PCLondon DataFrame
df_PCLondon.head(10)
Out [8]:
Postal Code District
0 E1 Whitechapel, Stepney, Mile End
1 E1W Wapping
2 E2 Bethnal Green, Shoreditch
3 E3 Bow, Bromley-by-Bow
4 E4 Chingford, Highams Park
5 E5 Clapton
6 E6 East Ham
7 E7 Forest Gate, Upton Park
8 E8 Hackney, Dalston
9 E9 Hackney, Homerton
In [9]:
# removing rows with NaN values
df_PCLondon=df_PCLondon[df_PCLondon['Postal Code'].str.contains("NaN") == False].reset_index()

# printing the df_PCLondon DataFrame
print(df_PCLondon)
     index Postal Code                                    District
0        0          E1              Whitechapel, Stepney, Mile End
1        1         E1W                                     Wapping
2        2          E2                   Bethnal Green, Shoreditch
3        3          E3                         Bow, Bromley-by-Bow
4        4          E4                     Chingford, Highams Park
5        5          E5                                     Clapton
6        6          E6                                    East Ham
7        7          E7                     Forest Gate, Upton Park
8        8          E8                            Hackney, Dalston
9        9          E9                           Hackney, Homerton
10      10         E10                                      Leyton
11      11         E11                                 Leytonstone
12      12         E12                                  Manor Park
13      13         E13                                    Plaistow
14      14         E14   Poplar, Millwall, Isle of Dogs, Docklands
15      15         E15                         Stratford, West Ham
16      16         E16     Canning Town, North Woolwich, Docklands
17      17         E17                                 Walthamstow
18      18         E18                              South Woodford
19      19         E20                                Olympic Park
20      21         WC1                       Bloomsbury, Grays Inn
21      22         WC2              Covent Garden, Holborn, Strand
22      24         EC1             Clerkenwell, Finsbury, Barbican
23      25         EC2                  Moorgate, Liverpool Street
24      26         EC3               Monument, Tower Hill, Aldgate
25      27         EC4                     Fleet Street, St. Pauls
26      29          N1             Islington, Barnsbury, Canonbury
27      30          N2                               East Finchley
28      31          N3                            Finchley Central
29      32          N4                  Finsbury Park, Manor House
30      33          N5                                    Highbury
31      34          N6                                    Highgate
32      35          N7                                    Holloway
33      36          N8                         Hornsey, Crouch End
34      37          N9                              Lower Edmonton
35      38         N10                                Muswell Hill
36      39         N11                Friern Barnet, New Southgate
37      40         N12               North Finchley, Woodside Park
38      41         N13                               Palmers Green
39      42         N14                                   Southgate
40      43         N15                               Seven Sisters
41      44         N16              Stoke Newington, Stamford Hill
42      45         N17                                   Tottenham
43      46         N18                              Upper Edmonton
44      47         N19                       Archway, Tufnell Park
45      48         N20                       Whetstone, Totteridge
46      49         N21                              Winchmore Hill
47      50         N22                Wood Green, Alexandra Palace
48      52         NW1                   Regents Park, Camden Town
49      53         NW2                        Cricklewood, Neasden
50      54         NW3                    Hampstead, Swiss Cottage
51      55         NW4                         Hendon, Brent Cross
52      56         NW5                                Kentish Town
53      57         NW6        West Hampstead, Kilburn, Queens Park
54      58         NW7                                   Mill Hill
55      59         NW8                               St Johns Wood
56      60         NW9                         Kinsbury, Colindale
57      61        NW10          Willesden, Harlesden, Kensal Green
58      62        NW11         Golders Green, Hampstead Gdn Suburb
59       0         SE1    Waterloo, Bermondsey, Southwark, Borough
60       1         SE2                                  Abbey Wood
61       2         SE3                  Blackheath, Westcombe Park
62       3         SE4      Brockley, Crofton Park, Honor Oak Park
63       4         SE5                                  Camberwell
64       5         SE6           Catford, Hither Green, Bellingham
65       6         SE7                                    Charlton
66       7         SE8                                    Deptford
67       8         SE9                          Eltham, Mottingham
68       9        SE10                                   Greenwich
69      10        SE11                                     Lambeth
70      11        SE12                             Lee, Grove Park
71      12        SE13                      Lewisham, Hither Green
72      13        SE14                   New Cross, New Cross Gate
73      14        SE15                            Peckham, Nunhead
74      15        SE16  Rotherhithe, South Bermonsey, Surrey Docks
75      16        SE17                 Walworth, Elephant & Castle
76      17        SE18                         Woolwich, Plumstead
77      18        SE19               Upper Norwood, Crystal Palace
78      19        SE20                              Penge, Anerley
79      20        SE21                                     Dulwich
80      21        SE22                                East Dulwich
81      22        SE23                                 Forest Hill
82      23        SE24                                  Herne Hill
83      24        SE25                               South Norwood
84      25        SE26                                    Sydenham
85      26        SE27                    West Norwood, Tulse Hill
86      27        SE28                                  Thamesmead
87      29         SW1             Westminster, Belgravia, Pimlico
88      30         SW2                     Brixton, Streatham Hill
89      31         SW3                           Chelsea, Brompton
90      32         SW4                                     Clapham
91      33         SW5                                 Earls Court
92      34         SW6                       Fulham, Parsons Green
93      35         SW7                            South Kensington
94      36         SW8                    South Lambeth, Nine Elms
95      37         SW9                          Stockwell, Brixton
96      38        SW10                   West Brompton, Worlds End
97      39        SW11                 Battersea, Clapham Junction
98      40        SW12                                      Balham
99      41        SW13                           Barnes, Castelnau
100     42        SW14                        Mortlake, East Sheen
101     43        SW15                          Putney, Roehampton
102     44        SW16                          Streatham, Norbury
103     45        SW17                                     Tooting
104     46        SW18                      Wandsworth, Earlsfield
105     47        SW19                           Wimbledon, Merton
106     48        SW20                South Wimbledon, Raynes Park
107     50          W1                   Mayfair, Marylebone, Soho
108     51          W2                       Bayswater, Paddington
109     52          W3                                       Acton
110     53          W4                                    Chiswick
111     54          W5                                      Ealing
112     55          W6                                 Hammersmith
113     56          W7                                     Hanwell
114     57          W8                                  Kensington
115     58          W9                  Maida Vale, Warwick Avenue
116     59         W10            Ladbroke Grove, North Kensington
117     60         W11                  Notting Hill, Holland Park
118     61         W12                              Shepherds Bush
119     62         W13                                 West Ealing
120     63         W14                             West Kensington

With the purpose of working with df_PCLondon DataFrame onwards, the index column must be removed.

In [10]:
# dropping the first column "index"
df_PCLondon.drop(['index'], axis = 1, inplace = True)

# displaying the first 10 results in the cleaned DataFrame
df_PCLondon.head(10)
Out [10]:
Postal Code District
0 E1 Whitechapel, Stepney, Mile End
1 E1W Wapping
2 E2 Bethnal Green, Shoreditch
3 E3 Bow, Bromley-by-Bow
4 E4 Chingford, Highams Park
5 E5 Clapton
6 E6 East Ham
7 E7 Forest Gate, Upton Park
8 E8 Hackney, Dalston
9 E9 Hackney, Homerton

Let's get the size of the df_PCLondon DataFrame.

In [11]:
# printing the size of the df_PCLondon DataFrame
print('The shape for the df_PCLondon DataFrame is:', df_PCLondon.shape)
The shape for the df_PCLondon DataFrame is: (121, 2)

The DataFrame contains 121 Postal Codes (rows) and 2 columns: Postal Code and Districts.

3.6. Adding the latitude and longitude coordinates to the DataFrame

A new function will be created to get the coordinates for all districts using ArcGIS, a powerful library useful for spatial analysis and mapping.

In [12]:
# creating a function to get the coordinates (latitude, longitude) for all districts
def get_geocode(arcgis_geocoder):
    
    # Initialize the location (latitude and longitude) to None
    lat_lng_coords = None
    
    # loop until the coordinates are obtained
    while(lat_lng_coords is None):
        g = geocoder.arcgis('{}, London, United Kingdom'.format(arcgis_geocoder))
        lat_lng_coords = g.latlng
    return lat_lng_coords

Let's test the function get_geocode created previously with two random Postal Codes to get their latitude and longitude coordinates.

In [13]:
# sampling two random chosen Postal codes to get their latitude and longitude coordinates using the function get_geocode
sample1 = get_geocode('NW11')
print(sample1)

sample2 = get_geocode('SW9')
print(sample2)
[51.576730000000055, -0.19694999999995844]
[51.47001000000006, -0.11248999999997977]

As illustrated the function get_geocode is working well. The function will be applied to df_PCLondon DataFrame.

In [14]:
# storing the location data (latitude and longitude) in the DataFrame df_PCLondon
postal_codes = df_PCLondon['Postal Code']
coordinates = [get_geocode(postal_codes) for postal_codes in postal_codes.tolist()]

# The coordinates are joined to df_PCLondon DataFrame to create a new DataFrame with the latitude and longitude
df_PCLondon_coordinates = pd.DataFrame(coordinates, columns = ['Latitude', 'Longitude'])
df_PCLondon['Latitude'] = df_PCLondon_coordinates['Latitude']
df_PCLondon['Longitude'] = df_PCLondon_coordinates['Longitude']

# displaying the first 10 results in the new merged DataFrame df_PCLondon
df_PCLondon.head(10)
Out [14]:
Postal Code District Latitude Longitude
0 E1 Whitechapel, Stepney, Mile End 51.520220 -0.054310
1 E1W Wapping 51.506282 -0.069426
2 E2 Bethnal Green, Shoreditch 51.526690 -0.062570
3 E3 Bow, Bromley-by-Bow 51.527020 -0.025940
4 E4 Chingford, Highams Park 51.617800 -0.009340
5 E5 Clapton 51.558970 -0.053230
6 E6 East Ham 51.532920 0.054610
7 E7 Forest Gate, Upton Park 51.546680 0.025580
8 E8 Hackney, Dalston 51.545050 -0.055320
9 E9 Hackney, Homerton 51.537770 -0.044800

The new DataFrame will be used to generate the venues for each district using Foursquare API.

3.7. Using Foursquare API to explore the districts and segment them

The geographical coordinates of London, U.K. will be obtained using Nominatim.

In [15]:
# getting the geographical coordinates of London city
address = 'London, United Kingdom'

geolocator = Nominatim(user_agent = "ln_explorer")
location = geolocator.geocode(address)
latitude = location.latitude
longitude = location.longitude
print('The geographical coordinates of London are: {}, {}'.format(latitude, longitude))
The geographical coordinates of London are: 51.5073219, -0.1276474

The districts of London city will be visualized using Folium library.

In [16]:
# creating a map of London city using latitude and longitude values
map_london = folium.Map(location=[latitude, longitude], zoom_start = 11)

# adding markers to London city map
for lat, lng, postal_code, district in zip(df_PCLondon['Latitude'], df_PCLondon['Longitude'], df_PCLondon['Postal Code'], df_PCLondon['District']):
    label = '{}, {}'.format(postal_code, district)
    label = folium.Popup(label, parse_html=True)
    folium.CircleMarker(
    [lat, lng],
    radius=5,
    popup=label,
    color='blue',
    fill=True,
    fill_color='#3186cc',
    fill_opacity=0.7,
    ).add_to(map_london)
    
map_london
Out [16]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [17]:
# defining Foursquare credentials and version
CLIENT_ID = 'SF3QURMDBEA11X4EDFJPY30R5AYACPJBBHL0I1EAVPYLGJC0' # Foursquare ID
CLIENT_SECRET = 'O5PEG4DFUJKZW3RNE4E2WSSJHUSVCIWPF3BQUNQJHIHZLUNJ' # Foursquare Secret
VERSION = '20180605' # Foursquare API version
LIMIT = 100 # A default Foursquare API limit value

print('Your credentials:')
print('CLIENT_ID: ' + CLIENT_ID)
print('CLIENT_SECRET' + CLIENT_SECRET)
Your credentials:
CLIENT_ID: SF3QURMDBEA11X4EDFJPY30R5AYACPJBBHL0I1EAVPYLGJC0
CLIENT_SECRETO5PEG4DFUJKZW3RNE4E2WSSJHUSVCIWPF3BQUNQJHIHZLUNJ

Let's create a function to repeat the same process to all districts in London city.

In [18]:
# exploring the districts in London city
def getNearbyVenues(names, latitudes, longitudes, radius=2000):
    
    venues_list=[]
    for name, lat, lng in zip(names, latitudes, longitudes):
        print(name)
        
        # create the API request URL
        url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
            CLIENT_ID,
            CLIENT_SECRET,
            VERSION,
            lat,
            lng,
            radius,
            LIMIT)
        
        # make the GET request
        results = requests.get(url).json()["response"]['groups'][0]['items']
        
        # return only relevant information for each nearby venue
        venues_list.append([(
            name,
            lat,
            lng,
            v['venue']['name'],
            v['venue']['location']['lat'],
            v['venue']['location']['lng'],
            v['venue']['categories'][0]['name']) for v in results])
        
    nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
    nearby_venues.columns = ['District',
                            'District Latitude',
                            'District Longitude',
                            'Venue',
                            'Venue Latitude',
                            'Venue Longitude',
                            'Venue Category']
    
    return(nearby_venues)
In [19]:
# returning a list of venues near the current location
london_venues = getNearbyVenues(names=df_PCLondon['District'],
                                latitudes=df_PCLondon['Latitude'],
                                longitudes=df_PCLondon['Longitude'])
Whitechapel, Stepney, Mile End
Wapping
Bethnal Green, Shoreditch
Bow, Bromley-by-Bow
Chingford, Highams Park
Clapton
East Ham
Forest Gate, Upton Park
Hackney, Dalston
Hackney, Homerton
Leyton
Leytonstone
Manor Park
Plaistow
Poplar, Millwall, Isle of Dogs, Docklands
Stratford, West Ham
Canning Town, North Woolwich, Docklands
Walthamstow
South Woodford
Olympic Park
Bloomsbury, Grays Inn
Covent Garden, Holborn, Strand
Clerkenwell, Finsbury, Barbican
Moorgate, Liverpool Street
Monument, Tower Hill, Aldgate
Fleet Street, St. Pauls
Islington, Barnsbury, Canonbury
East Finchley
Finchley Central
Finsbury Park, Manor House
Highbury
Highgate
Holloway
Hornsey, Crouch End
Lower Edmonton
Muswell Hill
Friern Barnet, New Southgate
North Finchley, Woodside Park
Palmers Green
Southgate
Seven Sisters
Stoke Newington, Stamford Hill
Tottenham
Upper Edmonton
Archway, Tufnell Park
Whetstone, Totteridge
Winchmore Hill
Wood Green, Alexandra Palace
Regents Park, Camden Town
Cricklewood, Neasden
Hampstead, Swiss Cottage
Hendon, Brent Cross
Kentish Town
West Hampstead, Kilburn, Queens Park
Mill Hill
St Johns Wood
Kinsbury, Colindale
Willesden, Harlesden, Kensal Green
Golders Green, Hampstead Gdn Suburb
Waterloo, Bermondsey, Southwark, Borough
Abbey Wood
Blackheath, Westcombe Park
Brockley, Crofton Park, Honor Oak Park
Camberwell
Catford, Hither Green, Bellingham
Charlton
Deptford
Eltham, Mottingham
Greenwich
Lambeth
Lee, Grove Park
Lewisham, Hither Green
New Cross, New Cross Gate
Peckham, Nunhead
Rotherhithe, South Bermonsey, Surrey Docks
Walworth, Elephant & Castle
Woolwich, Plumstead
Upper Norwood, Crystal Palace
Penge, Anerley
Dulwich
East Dulwich
Forest Hill
Herne Hill
South Norwood
Sydenham
West Norwood, Tulse Hill
Thamesmead
Westminster, Belgravia, Pimlico
Brixton, Streatham Hill
Chelsea, Brompton
Clapham
Earls Court
Fulham, Parsons Green
South Kensington
South Lambeth, Nine Elms
Stockwell, Brixton
West Brompton, Worlds End
Battersea, Clapham Junction
Balham
Barnes, Castelnau
Mortlake, East Sheen
Putney, Roehampton
Streatham, Norbury
Tooting
Wandsworth, Earlsfield
Wimbledon, Merton
South Wimbledon, Raynes Park
Mayfair, Marylebone, Soho
Bayswater, Paddington
Acton
Chiswick
Ealing
Hammersmith
Hanwell
Kensington
Maida Vale, Warwick Avenue
Ladbroke Grove, North Kensington
Notting Hill, Holland Park
Shepherds Bush
West Ealing
West Kensington

Let's check the size of the resulting DataFrame.

In [20]:
# printing the first 10 nearby venues in London city districts
london_venues.head(10)
Out [20]:
District District Latitude District Longitude Venue Venue Latitude Venue Longitude Venue Category
0 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Rinkoff's Bakery 51.519964 -0.053238 Bakery
1 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Mouse Tail Coffee Stories 51.519471 -0.058573 Coffee Shop
2 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Genesis Cinema 51.521036 -0.051073 Movie Theater
3 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Second Shot 51.527412 -0.056625 Coffee Shop
4 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Old Street Brewery & Taproom 51.526950 -0.056426 Brewery
5 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Stepney Green Park 51.517768 -0.047054 Park
6 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Renegade London Wine 51.527005 -0.056381 Wine Bar
7 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Mother Kelly's Bottle Shop and Tap Room 51.528413 -0.055843 Beer Bar
8 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Stepney City Farm 51.517009 -0.042995 Farm
9 Whitechapel, Stepney, Mile End 51.52022 -0.05431 Yoga Place E2 51.527365 -0.057697 Yoga Studio
In [21]:
# size of the london_venues DataFrame
print('The shape of london_venues DataFrame is:', london_venues.shape)
The shape of london_venues DataFrame is: (11145, 7)
In [22]:
# checking the number of venues in each district
london_venues.groupby('District').count()
Out [22]:
District Latitude District Longitude Venue Venue Latitude Venue Longitude Venue Category
District
Abbey Wood 19 19 19 19 19 19
Acton 100 100 100 100 100 100
Archway, Tufnell Park 100 100 100 100 100 100
Balham 100 100 100 100 100 100
Barnes, Castelnau 100 100 100 100 100 100
Battersea, Clapham Junction 100 100 100 100 100 100
Bayswater, Paddington 100 100 100 100 100 100
Bethnal Green, Shoreditch 100 100 100 100 100 100
Blackheath, Westcombe Park 92 92 92 92 92 92
Bloomsbury, Grays Inn 100 100 100 100 100 100
Bow, Bromley-by-Bow 100 100 100 100 100 100
Brixton, Streatham Hill 100 100 100 100 100 100
Brockley, Crofton Park, Honor Oak Park 100 100 100 100 100 100
Camberwell 100 100 100 100 100 100
Canning Town, North Woolwich, Docklands 100 100 100 100 100 100
Catford, Hither Green, Bellingham 64 64 64 64 64 64
Charlton 93 93 93 93 93 93
Chelsea, Brompton 100 100 100 100 100 100
Chingford, Highams Park 53 53 53 53 53 53
Chiswick 81 81 81 81 81 81
Clapham 100 100 100 100 100 100
Clapton 100 100 100 100 100 100
Clerkenwell, Finsbury, Barbican 100 100 100 100 100 100
Covent Garden, Holborn, Strand 100 100 100 100 100 100
Cricklewood, Neasden 100 100 100 100 100 100
Deptford 100 100 100 100 100 100
Dulwich 100 100 100 100 100 100
Ealing 100 100 100 100 100 100
Earls Court 100 100 100 100 100 100
East Dulwich 61 61 61 61 61 61
East Finchley 96 96 96 96 96 96
East Ham 84 84 84 84 84 84
Eltham, Mottingham 57 57 57 57 57 57
Finchley Central 88 88 88 88 88 88
Finsbury Park, Manor House 100 100 100 100 100 100
Fleet Street, St. Pauls 100 100 100 100 100 100
Forest Gate, Upton Park 96 96 96 96 96 96
Forest Hill 100 100 100 100 100 100
Friern Barnet, New Southgate 86 86 86 86 86 86
Fulham, Parsons Green 100 100 100 100 100 100
Golders Green, Hampstead Gdn Suburb 100 100 100 100 100 100
Greenwich 100 100 100 100 100 100
Hackney, Dalston 100 100 100 100 100 100
Hackney, Homerton 100 100 100 100 100 100
Hammersmith 100 100 100 100 100 100
Hampstead, Swiss Cottage 100 100 100 100 100 100
Hanwell 61 61 61 61 61 61
Hendon, Brent Cross 100 100 100 100 100 100
Herne Hill 100 100 100 100 100 100
Highbury 100 100 100 100 100 100
Highgate 100 100 100 100 100 100
Holloway 100 100 100 100 100 100
Hornsey, Crouch End 100 100 100 100 100 100
Islington, Barnsbury, Canonbury 100 100 100 100 100 100
Kensington 100 100 100 100 100 100
Kentish Town 100 100 100 100 100 100
Kinsbury, Colindale 100 100 100 100 100 100
Ladbroke Grove, North Kensington 100 100 100 100 100 100
Lambeth 100 100 100 100 100 100
Lee, Grove Park 55 55 55 55 55 55
Lewisham, Hither Green 100 100 100 100 100 100
Leyton 100 100 100 100 100 100
Leytonstone 38 38 38 38 38 38
Lower Edmonton 63 63 63 63 63 63
Maida Vale, Warwick Avenue 100 100 100 100 100 100
Manor Park 80 80 80 80 80 80
Mayfair, Marylebone, Soho 100 100 100 100 100 100
Mill Hill 32 32 32 32 32 32
Monument, Tower Hill, Aldgate 100 100 100 100 100 100
Moorgate, Liverpool Street 100 100 100 100 100 100
Mortlake, East Sheen 100 100 100 100 100 100
Muswell Hill 100 100 100 100 100 100
New Cross, New Cross Gate 100 100 100 100 100 100
North Finchley, Woodside Park 96 96 96 96 96 96
Notting Hill, Holland Park 100 100 100 100 100 100
Olympic Park 100 100 100 100 100 100
Palmers Green 93 93 93 93 93 93
Peckham, Nunhead 100 100 100 100 100 100
Penge, Anerley 100 100 100 100 100 100
Plaistow 78 78 78 78 78 78
Poplar, Millwall, Isle of Dogs, Docklands 100 100 100 100 100 100
Putney, Roehampton 100 100 100 100 100 100
Regents Park, Camden Town 100 100 100 100 100 100
Rotherhithe, South Bermonsey, Surrey Docks 100 100 100 100 100 100
Seven Sisters 100 100 100 100 100 100
Shepherds Bush 100 100 100 100 100 100
South Kensington 100 100 100 100 100 100
South Lambeth, Nine Elms 100 100 100 100 100 100
South Norwood 54 54 54 54 54 54
South Wimbledon, Raynes Park 100 100 100 100 100 100
South Woodford 84 84 84 84 84 84
Southgate 63 63 63 63 63 63
St Johns Wood 100 100 100 100 100 100
Stockwell, Brixton 100 100 100 100 100 100
Stoke Newington, Stamford Hill 100 100 100 100 100 100
Stratford, West Ham 100 100 100 100 100 100
Streatham, Norbury 93 93 93 93 93 93
Sydenham 100 100 100 100 100 100
Thamesmead 21 21 21 21 21 21
Tooting 100 100 100 100 100 100
Tottenham 100 100 100 100 100 100
Upper Edmonton 79 79 79 79 79 79
Upper Norwood, Crystal Palace 100 100 100 100 100 100
Walthamstow 100 100 100 100 100 100
Walworth, Elephant & Castle 100 100 100 100 100 100
Wandsworth, Earlsfield 100 100 100 100 100 100
Wapping 100 100 100 100 100 100
Waterloo, Bermondsey, Southwark, Borough 100 100 100 100 100 100
West Brompton, Worlds End 100 100 100 100 100 100
West Ealing 100 100 100 100 100 100
West Hampstead, Kilburn, Queens Park 100 100 100 100 100 100
West Kensington 100 100 100 100 100 100
West Norwood, Tulse Hill 100 100 100 100 100 100
Westminster, Belgravia, Pimlico 100 100 100 100 100 100
Whetstone, Totteridge 79 79 79 79 79 79
Whitechapel, Stepney, Mile End 100 100 100 100 100 100
Willesden, Harlesden, Kensal Green 79 79 79 79 79 79
Wimbledon, Merton 100 100 100 100 100 100
Winchmore Hill 59 59 59 59 59 59
Wood Green, Alexandra Palace 100 100 100 100 100 100
Woolwich, Plumstead 68 68 68 68 68 68

4. Methodology

The methodology applied in this project is as follows:

  1. Foursquare API will be used to explore all venues of all districts and analyze each district in London city.
  1. The most relevant venues to visit will be retrieved from the entire DataFrame and visualized in bar plots.
  1. The most common venues will be analyzed using word cloud to look for the most common words and translate them into venues.
  1. Each district will be grouped with the 10 most common venues.
  1. All districts in London city will be clustered, visualized and examined using k-means algorithm.
  1. The resulting clusters will be analyzed using word cloud to validate the analyses performed in previous sections.

5. Explanatory Analysis

This section consists in performing an explanatory data analysis and deriving some additional information from the raw data. The first step is analyzing each distric looking for venues.

5.1. Analyzing districts

In [23]:
# one hot encoding
london_onehot = pd.get_dummies(london_venues[['Venue Category']], prefix="", prefix_sep="")

# adding district column back to DataFrame
london_onehot['District'] = london_venues['District']

# moving district column to the first column
fixed_columns = [london_onehot.columns[-1]] + list(london_onehot.columns[:-1])
london_onehot = london_onehot[fixed_columns]

london_onehot.head()
Out [23]:
District Accessories Store Afghan Restaurant African Restaurant American Restaurant Antique Shop Aquarium Arcade Arepa Restaurant Argentinian Restaurant Art Gallery Art Museum Arts & Crafts Store Asian Restaurant Athletics & Sports Australian Restaurant Auto Workshop BBQ Joint Baby Store Bagel Shop Bakery Bar Baseball Field Beach Bed & Breakfast Beer Bar Beer Garden Beer Store Bike Shop Bistro Boat or Ferry Bookstore Boutique Bowling Alley Boxing Gym Brasserie Brazilian Restaurant Breakfast Spot Brewery Bridge Bubble Tea Shop Buddhist Temple Buffet Burger Joint Burrito Place Bus Station Bus Stop Butcher Cable Car Café Camera Store Canal Canal Lock Candy Store Cantonese Restaurant Caribbean Restaurant Castle Caucasian Restaurant Chaat Place Cheese Shop Chinese Restaurant Chocolate Shop Church Cigkofte Place Circus School Climbing Gym Clothing Store Club House Cocktail Bar Coffee Shop Comedy Club Comfort Food Restaurant Comic Shop Community Center Concert Hall Convenience Store Cosmetics Shop Costume Shop Coworking Space Creperie Cricket Ground Cupcake Shop Cycle Studio Dam Dance Studio Deli / Bodega Department Store Design Studio Dessert Shop Dim Sum Restaurant Diner Discount Store Distillery Dive Bar Doner Restaurant Donut Shop Dry Cleaner Dumpling Restaurant Eastern European Restaurant Electronics Store Empanada Restaurant English Restaurant Escape Room Ethiopian Restaurant Event Space Exhibit Fabric Shop Falafel Restaurant Farm Farmers Market Fast Food Restaurant Film Studio Financial or Legal Service Fish & Chips Shop Fish Market Fishing Store Flea Market Flower Shop Food Food & Drink Shop Food Court Food Stand Food Truck Forest Fountain French Restaurant Fried Chicken Joint Fruit & Vegetable Store Furniture / Home Store Gaming Cafe Garden Garden Center Gas Station Gastropub Gay Bar Gelato Shop General Entertainment Gift Shop Go Kart Track Golf Course Golf Driving Range Gourmet Shop Greek Restaurant Grilled Meat Restaurant Grocery Store Gym Gym / Fitness Center Gym Pool Halal Restaurant Harbor / Marina Hardware Store Health & Beauty Service Health Food Store Hill Himalayan Restaurant Historic Site History Museum Hobby Shop Hockey Field Hookah Bar Hostel Hotel Hotel Bar Hungarian Restaurant Ice Cream Shop Indian Restaurant Indie Movie Theater Indie Theater Indonesian Restaurant Indoor Play Area Intersection Irish Pub Italian Restaurant Japanese Restaurant Jazz Club Jewelry Store Juice Bar Kebab Restaurant Korean Restaurant Kosher Restaurant Lake Latin American Restaurant Lebanese Restaurant Light Rail Station Lighthouse Lighting Store Lingerie Store Liquor Store Lounge Malay Restaurant Market Martial Arts School Massage Studio Mediterranean Restaurant Metro Station Mexican Restaurant Middle Eastern Restaurant Mini Golf Miscellaneous Shop Mobile Phone Shop Modern European Restaurant Monument / Landmark Moroccan Restaurant Motorcycle Shop Movie Theater Multiplex Museum Music Store Music Venue Nail Salon Nature Preserve Neighborhood New American Restaurant Nightclub Noodle House North Indian Restaurant Observatory Office Okonomiyaki Restaurant Opera House Optical Shop Organic Grocery Other Repair Shop Outdoor Gym Outdoor Sculpture Outdoor Supply Store Outdoors & Recreation Outlet Mall Paintball Field Pakistani Restaurant Palace Paper / Office Supplies Store Park Pastry Shop Pedestrian Plaza Performing Arts Venue Persian Restaurant Peruvian Restaurant Pet Store Pharmacy Photography Studio Pie Shop Pier Pilates Studio Pizza Place Planetarium Platform Playground Plaza Poke Place Polish Restaurant Pool Portuguese Restaurant Print Shop Pub RV Park Rafting Ramen Restaurant Record Shop Recording Studio Recreation Center Rental Car Location Reservoir Residential Building (Apartment / Condo) Restaurant River Rock Climbing Spot Roof Deck Rugby Pitch Rugby Stadium Russian Restaurant Sake Bar Salad Place Salon / Barbershop Sandwich Place Scandinavian Restaurant Scenic Lookout Science Museum Sculpture Garden Seafood Restaurant Shaanxi Restaurant Shabu-Shabu Restaurant Shoe Store Shop & Service Shopping Mall Shopping Plaza Skate Park Skating Rink Snack Place Soccer Field Soccer Stadium Social Club South American Restaurant South Indian Restaurant Southern / Soul Food Restaurant Souvenir Shop Souvlaki Shop Spa Spanish Restaurant Speakeasy Sporting Goods Shop Sports Bar Sports Club Sri Lankan Restaurant Stables Stadium Stationery Store Steakhouse Street Art Street Food Gathering Student Center Supermarket Sushi Restaurant Taco Place Taiwanese Restaurant Tapas Restaurant Tea Room Tennis Court Tennis Stadium Thai Restaurant Theater Thrift / Vintage Store Tourist Information Center Toy / Game Store Track Track Stadium Trail Train Station Tram Station Tunnel Turkish Restaurant Udon Restaurant University Vegetarian / Vegan Restaurant Video Game Store Vietnamese Restaurant Warehouse Store Waterfront Whisky Bar Windmill Wine Bar Wine Shop Wings Joint Women's Store Xinjiang Restaurant Yoga Studio Zoo Zoo Exhibit
0 Whitechapel, Stepney, Mile End 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 Whitechapel, Stepney, Mile End 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 Whitechapel, Stepney, Mile End 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 Whitechapel, Stepney, Mile End 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 Whitechapel, Stepney, Mile End 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Let's examine the new DataFrame size.

In [24]:
# getting the size of the london_onehot DataFrame
london_onehot.shape
Out [24]:
(11145, 348)

The most relevant venue categories will be counted with the purpose of evaluating whether or not London is a good place to travel.

In [25]:
# getting the number of Restaurants in London City
print('The number of Restaurants in London city is:', (london_onehot['Restaurant'].values==1).sum())

# getting the number of Train Stations in London City
print('The number of Train Stations in London city is:', (london_onehot['Train Station'].values==1).sum())

# getting the number of Aquariums in London City
print('The number of Aquariums in London city is:', (london_onehot['Aquarium'].values==1).sum())

# getting the number of Art Museums in London City
print('The number of Art Museums in London city is:', (london_onehot['Art Museum'].values==1).sum())

# getting the number of Bookstores in London City
print('The number of Bookstores in London city is:', (london_onehot['Bookstore'].values==1).sum())

# getting the number of Gyms in London City
print('The number of Gyms in London city is:', (london_onehot['Gym'].values==1).sum())

# getting the number of Hotels in London City
print('The number of Hotels in London city is:', (london_onehot['Hotel'].values==1).sum())

# getting the number of Bars in London City
print('The number of Bars in London city is:', (london_onehot['Bar'].values==1).sum())

# getting the number of Shopping Malls in London City
print('The number of Shopping Malls in London city is:', (london_onehot['Shopping Mall'].values==1).sum())

# getting the number of Gift Shops in London City
print('The number of Gift Shops in London city is:', (london_onehot['Gift Shop'].values==1).sum())

# getting the number of Theaters in London City
print('The number of Theaters in London city is:', (london_onehot['Theater'].values==1).sum())

# getting the number of Zoos in London City
print('The number of Zoos in London city is:', (london_onehot['Zoo'].values==1).sum())
The number of Restaurants in London city is: 163
The number of Train Stations in London city is: 57
The number of Aquariums in London city is: 4
The number of Art Museums in London city is: 20
The number of Bookstores in London city is: 85
The number of Gyms in London city is: 59
The number of Hotels in London city is: 254
The number of Bars in London city is: 159
The number of Shopping Malls in London city is: 20
The number of Gift Shops in London city is: 26
The number of Theaters in London city is: 89
The number of Zoos in London city is: 4

Based on this information retrieved from london_onehot DataFrame containing the number of restaurants, train stations, aquariums, art museums, bookstores, gyms, hotels, bars, shopping malls, gift shops, theatres and zoos in London city, a new DataFrame will be created to visualize these venues in a bar plot.

In [26]:
# building a new DataFrame containing the venues previously explored
data1 ={'Venue Type': ['Restaurants', 'Train Stations', 'Aquariums', 'Art Museums', 'Bookstores', 
                 'Gyms', 'Hotels', 'Bars', 'Shopping Malls', 'Gift Shops', 'Theaters', 'Zoos'],
      'Total Venues': [163, 57, 4, 20, 83, 53, 243, 160, 20, 23, 92, 5]}

df_london_num_venues = pd.DataFrame(data1, columns = ['Venue Type', 'Total Venues'])

print(df_london_num_venues)
        Venue Type  Total Venues
0      Restaurants           163
1   Train Stations            57
2        Aquariums             4
3      Art Museums            20
4       Bookstores            83
5             Gyms            53
6           Hotels           243
7             Bars           160
8   Shopping Malls            20
9       Gift Shops            23
10        Theaters            92
11            Zoos             5

Let's build the bar plot with the most relevant venues in London city.

In [27]:
# magic function that renders the figure in a notebook
%matplotlib inline 

# bar plot of the 'df_london_num_venues' DataFrame
plt.figure(figsize=(12, 8))

df3 = df_london_num_venues.sort_values('Total Venues', ascending=False)
plt.bar(df3['Venue Type'], df3['Total Venues'])

# title
plt.title('Most relevant venues in London city', fontsize=16)

# labels
plt.xlabel('Venue Type', fontsize=14)
plt.ylabel('Total Venues', fontsize=14)

# rotating x label
plt.xticks(rotation=60)

# increasing the default intervals for y-axis
plt.yticks(np.arange(0, 270, 20))

# displaying the bar plot
plt.show()

As can be noted from the bar plot above, from the venues selected, hotels are the most common venue in London city, followed by restaurants. Now hotels will be grouped by district to find which districts have most hotels in London city.

In [28]:
# grouping london_onehot DataFrame by district and getting the Hotel column with the total of hotels by district
df_london_hotels = london_onehot.groupby('District', axis=0)['Hotel'].sum().reset_index()

# printing the first 10 results
print(df_london_hotels.head(10))
                      District  Hotel
0                   Abbey Wood      0
1                        Acton      5
2        Archway, Tufnell Park      0
3                       Balham      0
4            Barnes, Castelnau      0
5  Battersea, Clapham Junction      1
6        Bayswater, Paddington      6
7    Bethnal Green, Shoreditch      2
8   Blackheath, Westcombe Park      1
9        Bloomsbury, Grays Inn      4

Let's build the bar plot containing the 10 districts with the largest number of hotels.

In [29]:
# magic function that renders the figure in a notebook
%matplotlib inline 

# bar plot of the 'df_london_hotels' DataFrame
plt.figure(figsize=(12, 8))

df4 = df_london_hotels.sort_values('Hotel', ascending=False).head(10)
plt.bar(df4['District'], df4['Hotel'])

# title
plt.title('Top 10 districts by hotel availability', fontsize=16)

# labels
plt.xlabel('District', fontsize=14)
plt.ylabel('Total of Hotels', fontsize=14)

# rotating x label
plt.xticks(rotation=90)

# increasing the default intervals for y-axis
plt.yticks(np.arange(0, 17, 1))

# displaying the bar plot
plt.show()

As previously mentioned, restaurants is the next category from the venues selected. The next analysis consists in grouping restaurants by district to find which districts have most restaurants in London city. National and international restaurants will be counted to get an idea about the variety of cuisines available in London city restaurants.

In [30]:
# getting the number of African Restaurants in London City
print('The number of African Restaurants in London city is:', (london_onehot['African Restaurant'].values==1).sum())

# getting the number of American Restaurants in London City
print('The number of American Restaurants in London city is:', (london_onehot['American Restaurant'].values==1).sum())

# getting the number of Asian Restaurants in London City
print('The number of Asian Restaurants in London city is:', (london_onehot['Asian Restaurant'].values==1).sum())

# getting the number of Chinese Restaurants in London City
print('The number of Chinese Restaurants in London city is:', (london_onehot['Chinese Restaurant'].values==1).sum())

# getting the number of English Restaurants in London City
print('The number of English Restaurants in London city is:', (london_onehot['English Restaurant'].values==1).sum())

# getting the number of Indian Restaurants in London City
print('The number of Indian Restaurants in London city is:', (london_onehot['Indian Restaurant'].values==1).sum())

# getting the number of Italianh Restaurants in London City
print('The number of Italian Restaurants in London city is:', (london_onehot['Italian Restaurant'].values==1).sum())

# getting the number of Japanese Restaurants in London City
print('The number of Japanese Restaurants in London city is:', (london_onehot['Japanese Restaurant'].values==1).sum())

# getting the number of Spanish Restaurants in London City
print('The number of Spanish Restaurants in London city is:', (london_onehot['Spanish Restaurant'].values==1).sum())

# getting the number of Turkish Restaurants in London City
print('The number of Turkish Restaurants in London city is:', (london_onehot['Turkish Restaurant'].values==1).sum())
The number of African Restaurants in London city is: 22
The number of American Restaurants in London city is: 14
The number of Asian Restaurants in London city is: 49
The number of Chinese Restaurants in London city is: 33
The number of English Restaurants in London city is: 42
The number of Indian Restaurants in London city is: 170
The number of Italian Restaurants in London city is: 271
The number of Japanese Restaurants in London city is: 88
The number of Spanish Restaurants in London city is: 18
The number of Turkish Restaurants in London city is: 143

A new DataFrame based on this information retrieved from london_onehot DataFrame will be created containing the number of restaurants by origin or cuisine type in London city with the purpose of visualizing these restaurants in a bar plot.

In [31]:
# creating a new DataFrame containing the different restaurants by cuisine type in London city
data2 ={'Restaurant Type': ['African', 'American', 'Asian', 'Chinese', 'English', 'Indian', 'Italian', 'Japanese',
                          'Spanish', 'Turkish'],
      'Total of Restaurants': [23, 14, 44, 31, 44, 167, 280, 86, 18, 142]}

df_london_restaurant_types = pd.DataFrame(data2, columns = ['Restaurant Type', 'Total of Restaurants'])

print(df_london_restaurant_types)
  Restaurant Type  Total of Restaurants
0         African                    23
1        American                    14
2           Asian                    44
3         Chinese                    31
4         English                    44
5          Indian                   167
6         Italian                   280
7        Japanese                    86
8         Spanish                    18
9         Turkish                   142

Let's build the bar plot with the total of different types of restaurants in London city.

In [32]:
# magic function that renders the figure in a notebook
%matplotlib inline 

# bar plot of the 'df_london_restaurant_types' DataFrame
plt.figure(figsize=(12, 8))

df6 = df_london_restaurant_types.sort_values('Total of Restaurants', ascending=False)
plt.bar(df6['Restaurant Type'], df6['Total of Restaurants'])

# title
plt.title('Restaurants in London city by cuisine type', fontsize=16)

# labels
plt.xlabel('Restaurant Type', fontsize=14)
plt.ylabel('Total of Restaurants', fontsize=14)

# increasing the default intervals for y-axis
plt.yticks(np.arange(0, 300, 20))

# displaying the bar plot
plt.show()

As observed above, Italian and Indian restaurants lead the cuisines in London city. A more detailed analysis will reveal the spatial distribution of such restaurants by district.

In [33]:
# grouping london_onehot DataFrame by district and getting the Italian Restaurants column with the number of these restaurants by district
df_london_italian_restaurants = london_onehot.groupby('District', axis=0)['Italian Restaurant'].sum().reset_index()

# printing the first 10 results
print(df_london_italian_restaurants.head(10))
                      District  Italian Restaurant
0                   Abbey Wood                   0
1                        Acton                   2
2        Archway, Tufnell Park                   5
3                       Balham                   5
4            Barnes, Castelnau                   3
5  Battersea, Clapham Junction                   5
6        Bayswater, Paddington                   2
7    Bethnal Green, Shoreditch                   3
8   Blackheath, Westcombe Park                   3
9        Bloomsbury, Grays Inn                   0

Let's build the bar plot containing the 10 districts with the largest number of italian restaurants.

In [34]:
# magic function that renders the figure in a notebook
%matplotlib inline 

# bar plot of the 'df_london_italian_restaurants' DataFrame
plt.figure(figsize=(12, 8))

df7 = df_london_italian_restaurants.sort_values('Italian Restaurant', ascending=False).head(10)
plt.bar(df7['District'], df7['Italian Restaurant'])

# title
plt.title('Top 10 districts by Italian Restaurants', fontsize=16)

# labels
plt.xlabel('District', fontsize=14)
plt.ylabel('Total of Italian Restaurants', fontsize=14)

# rotating x label
plt.xticks(rotation=90)

# increasing the default intervals for y-axis
plt.yticks(np.arange(0, 8, 1))

# displaying the bar plot
plt.show()
In [35]:
# grouping london_onehot DataFrame by district and getting the Indian Restaurants column with the number of these restaurants by district
df_london_indian_restaurants = london_onehot.groupby('District', axis=0)['Indian Restaurant'].sum().reset_index()

# printing the first 10 results
print(df_london_indian_restaurants.head(10))
                      District  Indian Restaurant
0                   Abbey Wood                  0
1                        Acton                  1
2        Archway, Tufnell Park                  2
3                       Balham                  1
4            Barnes, Castelnau                  1
5  Battersea, Clapham Junction                  1
6        Bayswater, Paddington                  1
7    Bethnal Green, Shoreditch                  2
8   Blackheath, Westcombe Park                  1
9        Bloomsbury, Grays Inn                  1

Let's build the bar plot containing the 10 districts with the largest number of indian restaurants.

In [36]:
# magic function that renders the figure in a notebook
%matplotlib inline 

# bar plot of the 'df_london_indian_restaurants' DataFrame
plt.figure(figsize=(12, 8))

df8 = df_london_indian_restaurants.sort_values('Indian Restaurant', ascending=False).head(10)
plt.bar(df8['District'], df8['Indian Restaurant'])

# title
plt.title('Top 10 districts by Indian Restaurants', fontsize=16)

# labels
plt.xlabel('District', fontsize=14)
plt.ylabel('Total of Indian Restaurants', fontsize=14)

# rotating x label
plt.xticks(rotation=90)

# increasing the default intervals for y-axis
plt.yticks(np.arange(0, 9, 1))

# displaying the bar plot
plt.show()

The next step consists in grouping rows by district and taking the mean of the frequency of occurrence of each category.

In [37]:
# grouping rows by district
london_grouped = london_onehot.groupby('District').mean().reset_index()
london_grouped.head()
Out [37]:
District Accessories Store Afghan Restaurant African Restaurant American Restaurant Antique Shop Aquarium Arcade Arepa Restaurant Argentinian Restaurant Art Gallery Art Museum Arts & Crafts Store Asian Restaurant Athletics & Sports Australian Restaurant Auto Workshop BBQ Joint Baby Store Bagel Shop Bakery Bar Baseball Field Beach Bed & Breakfast Beer Bar Beer Garden Beer Store Bike Shop Bistro Boat or Ferry Bookstore Boutique Bowling Alley Boxing Gym Brasserie Brazilian Restaurant Breakfast Spot Brewery Bridge Bubble Tea Shop Buddhist Temple Buffet Burger Joint Burrito Place Bus Station Bus Stop Butcher Cable Car Café Camera Store Canal Canal Lock Candy Store Cantonese Restaurant Caribbean Restaurant Castle Caucasian Restaurant Chaat Place Cheese Shop Chinese Restaurant Chocolate Shop Church Cigkofte Place Circus School Climbing Gym Clothing Store Club House Cocktail Bar Coffee Shop Comedy Club Comfort Food Restaurant Comic Shop Community Center Concert Hall Convenience Store Cosmetics Shop Costume Shop Coworking Space Creperie Cricket Ground Cupcake Shop Cycle Studio Dam Dance Studio Deli / Bodega Department Store Design Studio Dessert Shop Dim Sum Restaurant Diner Discount Store Distillery Dive Bar Doner Restaurant Donut Shop Dry Cleaner Dumpling Restaurant Eastern European Restaurant Electronics Store Empanada Restaurant English Restaurant Escape Room Ethiopian Restaurant Event Space Exhibit Fabric Shop Falafel Restaurant Farm Farmers Market Fast Food Restaurant Film Studio Financial or Legal Service Fish & Chips Shop Fish Market Fishing Store Flea Market Flower Shop Food Food & Drink Shop Food Court Food Stand Food Truck Forest Fountain French Restaurant Fried Chicken Joint Fruit & Vegetable Store Furniture / Home Store Gaming Cafe Garden Garden Center Gas Station Gastropub Gay Bar Gelato Shop General Entertainment Gift Shop Go Kart Track Golf Course Golf Driving Range Gourmet Shop Greek Restaurant Grilled Meat Restaurant Grocery Store Gym Gym / Fitness Center Gym Pool Halal Restaurant Harbor / Marina Hardware Store Health & Beauty Service Health Food Store Hill Himalayan Restaurant Historic Site History Museum Hobby Shop Hockey Field Hookah Bar Hostel Hotel Hotel Bar Hungarian Restaurant Ice Cream Shop Indian Restaurant Indie Movie Theater Indie Theater Indonesian Restaurant Indoor Play Area Intersection Irish Pub Italian Restaurant Japanese Restaurant Jazz Club Jewelry Store Juice Bar Kebab Restaurant Korean Restaurant Kosher Restaurant Lake Latin American Restaurant Lebanese Restaurant Light Rail Station Lighthouse Lighting Store Lingerie Store Liquor Store Lounge Malay Restaurant Market Martial Arts School Massage Studio Mediterranean Restaurant Metro Station Mexican Restaurant Middle Eastern Restaurant Mini Golf Miscellaneous Shop Mobile Phone Shop Modern European Restaurant Monument / Landmark Moroccan Restaurant Motorcycle Shop Movie Theater Multiplex Museum Music Store Music Venue Nail Salon Nature Preserve Neighborhood New American Restaurant Nightclub Noodle House North Indian Restaurant Observatory Office Okonomiyaki Restaurant Opera House Optical Shop Organic Grocery Other Repair Shop Outdoor Gym Outdoor Sculpture Outdoor Supply Store Outdoors & Recreation Outlet Mall Paintball Field Pakistani Restaurant Palace Paper / Office Supplies Store Park Pastry Shop Pedestrian Plaza Performing Arts Venue Persian Restaurant Peruvian Restaurant Pet Store Pharmacy Photography Studio Pie Shop Pier Pilates Studio Pizza Place Planetarium Platform Playground Plaza Poke Place Polish Restaurant Pool Portuguese Restaurant Print Shop Pub RV Park Rafting Ramen Restaurant Record Shop Recording Studio Recreation Center Rental Car Location Reservoir Residential Building (Apartment / Condo) Restaurant River Rock Climbing Spot Roof Deck Rugby Pitch Rugby Stadium Russian Restaurant Sake Bar Salad Place Salon / Barbershop Sandwich Place Scandinavian Restaurant Scenic Lookout Science Museum Sculpture Garden Seafood Restaurant Shaanxi Restaurant Shabu-Shabu Restaurant Shoe Store Shop & Service Shopping Mall Shopping Plaza Skate Park Skating Rink Snack Place Soccer Field Soccer Stadium Social Club South American Restaurant South Indian Restaurant Southern / Soul Food Restaurant Souvenir Shop Souvlaki Shop Spa Spanish Restaurant Speakeasy Sporting Goods Shop Sports Bar Sports Club Sri Lankan Restaurant Stables Stadium Stationery Store Steakhouse Street Art Street Food Gathering Student Center Supermarket Sushi Restaurant Taco Place Taiwanese Restaurant Tapas Restaurant Tea Room Tennis Court Tennis Stadium Thai Restaurant Theater Thrift / Vintage Store Tourist Information Center Toy / Game Store Track Track Stadium Trail Train Station Tram Station Tunnel Turkish Restaurant Udon Restaurant University Vegetarian / Vegan Restaurant Video Game Store Vietnamese Restaurant Warehouse Store Waterfront Whisky Bar Windmill Wine Bar Wine Shop Wings Joint Women's Store Xinjiang Restaurant Yoga Studio Zoo Zoo Exhibit
0 Abbey Wood 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.052632 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.052632 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.00 0.105263 0.00 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.052632 0.0 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.00 0.00 0.00 0.0 0.0 0.00 0.0 0.105263 0.00 0.052632 0.0 0.00 0.0 0.052632 0.0 0.0 0.0 0.0 0.052632 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.00 0.00 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.00 0.00 0.0 0.052632 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.0 0.052632 0.0 0.0 0.0 0.0 0.00 0.0 0.052632 0.00 0.00 0.0 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.157895 0.00 0.0 0.0 0.00 0.00 0.00 0.0 0.00 0.00 0.0 0.0 0.0 0.00 0.0 0.052632 0.052632 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.052632 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.0 0.00 0.0 0.0
1 Acton 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.01 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.03 0.00 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.02 0.01 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.02 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.08 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.010000 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.01 0.0 0.00 0.020000 0.01 0.0 0.01 0.00 0.0 0.00 0.0 0.0 0.01 0.0 0.0 0.00 0.0 0.0 0.01 0.00 0.0 0.000000 0.0 0.0 0.00 0.0 0.03 0.0 0.00 0.0 0.00 0.01 0.00 0.0 0.0 0.00 0.0 0.070000 0.01 0.060000 0.0 0.01 0.0 0.010000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.0 0.03 0.0 0.05 0.0 0.0 0.00 0.01 0.00 0.0 0.0 0.0 0.0 0.0 0.02 0.02 0.0 0.0 0.0 0.00 0.01 0.0 0.000000 0.0 0.02 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.04 0.01 0.0 0.0 0.0 0.0 0.01 0.0 0.01 0.0 0.02 0.0 0.01 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.04 0.01 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.0 0.0 0.02 0.0 0.000000 0.01 0.00 0.0 0.0 0.00 0.01 0.0 0.06 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.00 0.0 0.0 0.01 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.020000 0.01 0.0 0.0 0.00 0.00 0.00 0.0 0.00 0.00 0.0 0.0 0.0 0.00 0.0 0.000000 0.020000 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.010000 0.00 0.0 0.00 0.00 0.02 0.0 0.00 0.0 0.00 0.0 0.0
2 Archway, Tufnell Park 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.05 0.01 0.0 0.0 0.0 0.00 0.0 0.01 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.06 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.07 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.01 0.01 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.010000 0.0 0.0 0.00 0.0 0.01 0.0 0.0 0.0 0.00 0.0 0.00 0.000000 0.00 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.01 0.0 0.0 0.01 0.01 0.0 0.000000 0.0 0.0 0.00 0.0 0.04 0.0 0.00 0.0 0.00 0.00 0.00 0.0 0.0 0.01 0.0 0.000000 0.00 0.000000 0.0 0.00 0.0 0.000000 0.0 0.0 0.0 0.0 0.010000 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.01 0.02 0.00 0.0 0.0 0.0 0.0 0.0 0.05 0.03 0.0 0.0 0.0 0.01 0.01 0.0 0.000000 0.0 0.00 0.0 0.0 0.0 0.0 0.01 0.01 0.0 0.00 0.0 0.0 0.02 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.01 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.02 0.00 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.0 0.0 0.05 0.0 0.000000 0.00 0.00 0.0 0.0 0.01 0.00 0.0 0.19 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.02 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.01 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.010000 0.01 0.0 0.0 0.01 0.00 0.01 0.0 0.01 0.01 0.0 0.0 0.0 0.00 0.0 0.020000 0.000000 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.01 0.000000 0.00 0.0 0.00 0.02 0.01 0.0 0.01 0.0 0.00 0.0 0.0
3 Balham 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.05 0.03 0.0 0.0 0.0 0.01 0.0 0.01 0.0 0.01 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.02 0.01 0.0 0.0 0.0 0.0 0.02 0.0 0.0 0.0 0.01 0.0 0.03 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.10 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.02 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.01 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.01 0.010000 0.00 0.0 0.02 0.01 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.05 0.00 0.0 0.000000 0.0 0.0 0.01 0.0 0.01 0.0 0.01 0.0 0.00 0.00 0.00 0.0 0.0 0.00 0.0 0.010000 0.00 0.010000 0.0 0.00 0.0 0.000000 0.0 0.0 0.0 0.0 0.010000 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.01 0.01 0.00 0.0 0.0 0.0 0.0 0.0 0.05 0.01 0.0 0.0 0.0 0.00 0.00 0.0 0.000000 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.01 0.0 0.0 0.00 0.0 0.0 0.01 0.00 0.0 0.0 0.0 0.0 0.01 0.0 0.01 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.06 0.00 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.0 0.0 0.04 0.0 0.000000 0.00 0.01 0.0 0.0 0.01 0.00 0.0 0.11 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.02 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.00 0.01 0.0 0.0 0.01 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.02 0.0 0.0 0.0 0.010000 0.00 0.0 0.0 0.01 0.00 0.00 0.0 0.00 0.00 0.0 0.0 0.0 0.00 0.0 0.000000 0.000000 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.000000 0.00 0.0 0.01 0.01 0.01 0.0 0.00 0.0 0.01 0.0 0.0
4 Barnes, Castelnau 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.00 0.01 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.01 0.01 0.0 0.0 0.0 0.00 0.0 0.01 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.01 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.07 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.05 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.0 0.00 0.0 0.04 0.000000 0.00 0.0 0.00 0.00 0.0 0.01 0.0 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.01 0.00 0.0 0.000000 0.0 0.0 0.01 0.0 0.04 0.0 0.01 0.0 0.01 0.00 0.01 0.0 0.0 0.00 0.0 0.030000 0.02 0.020000 0.0 0.00 0.0 0.000000 0.0 0.0 0.0 0.0 0.020000 0.0 0.0 0.0 0.00 0.0 0.00 0.0 0.0 0.00 0.01 0.01 0.0 0.0 0.0 0.0 0.0 0.03 0.02 0.0 0.0 0.0 0.00 0.00 0.0 0.000000 0.0 0.01 0.0 0.0 0.0 0.0 0.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.0 0.0 0.00 0.0 0.01 0.0 0.00 0.0 0.00 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.07 0.00 0.0 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.0 0.0 0.01 0.0 0.000000 0.02 0.00 0.0 0.0 0.00 0.00 0.0 0.17 0.0 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.03 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.00 0.00 0.0 0.0 0.00 0.0 0.0 0.00 0.01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.02 0.0 0.0 0.0 0.0 0.00 0.0 0.0 0.0 0.000000 0.01 0.0 0.0 0.01 0.02 0.02 0.0 0.01 0.00 0.0 0.0 0.0 0.01 0.0 0.020000 0.010000 0.0 0.0 0.01 0.0 0.0 0.0 0.0 0.00 0.000000 0.01 0.0 0.00 0.01 0.00 0.0 0.00 0.0 0.00 0.0 0.0

Let's confirm the new size.

In [38]:
# size of the london_grouped DataFrame
london_grouped.shape
Out [38]:
(121, 348)
In [39]:
# grouping the 10 common venues in each district
num_top_venues = 10 # Top common venues needed
for district in london_grouped['District']:
    print("---"+district+"---")
    temp = london_grouped[london_grouped['District'] == district].T.reset_index()
    temp.columns = ['venue', 'freq']
    temp = temp.iloc[1:]
    temp['freq'] = temp['freq'].astype(float)
    temp = temp.round({'freq': 2})
    print(temp.sort_values('freq', ascending = False).reset_index(drop = True).head(num_top_venues))
    print('\n')
---Abbey Wood---
                    venue  freq
0             Supermarket  0.16
1           Grocery Store  0.11
2    Fast Food Restaurant  0.11
3                    Lake  0.05
4                Platform  0.05
5  Furniture / Home Store  0.05
6    Gym / Fitness Center  0.05
7          Hardware Store  0.05
8          Clothing Store  0.05
9           Historic Site  0.05


---Acton---
                       venue  freq
0                Coffee Shop  0.08
1              Grocery Store  0.07
2       Gym / Fitness Center  0.06
3                        Pub  0.06
4                      Hotel  0.05
5                       Park  0.04
6  Middle Eastern Restaurant  0.04
7                 Hookah Bar  0.03
8                     Bakery  0.03
9                  Gastropub  0.03


---Archway, Tufnell Park---
                 venue  freq
0                  Pub  0.19
1          Coffee Shop  0.07
2                 Café  0.06
3   Italian Restaurant  0.05
4               Bakery  0.05
5          Pizza Place  0.05
6            Gastropub  0.04
7  Japanese Restaurant  0.03
8                 Park  0.02
9                Trail  0.02


---Balham---
                venue  freq
0                 Pub  0.11
1         Coffee Shop  0.10
2                Park  0.06
3  Italian Restaurant  0.05
4              Bakery  0.05
5   French Restaurant  0.05
6         Pizza Place  0.04
7                Café  0.03
8                 Bar  0.03
9       Deli / Bodega  0.02


---Barnes, Castelnau---
                 venue  freq
0                  Pub  0.17
1                 Café  0.07
2                 Park  0.07
3          Coffee Shop  0.05
4            Gastropub  0.04
5       Farmers Market  0.04
6   Italian Restaurant  0.03
7        Grocery Store  0.03
8           Restaurant  0.03
9  Japanese Restaurant  0.02


---Battersea, Clapham Junction---
                venue  freq
0                 Pub  0.09
1         Coffee Shop  0.07
2                Café  0.07
3  Italian Restaurant  0.05
4         Pizza Place  0.04
5                Park  0.04
6              Bakery  0.04
7   French Restaurant  0.03
8      Breakfast Spot  0.03
9        Cocktail Bar  0.03


---Bayswater, Paddington---
                venue  freq
0                 Pub  0.07
1               Hotel  0.06
2                Café  0.05
3              Garden  0.04
4          Restaurant  0.04
5         Coffee Shop  0.04
6    Greek Restaurant  0.03
7         Art Gallery  0.03
8  Persian Restaurant  0.03
9              Bakery  0.03


---Bethnal Green, Shoreditch---
                venue  freq
0         Coffee Shop  0.13
1              Bakery  0.06
2                Café  0.05
3           Bookstore  0.04
4          Restaurant  0.04
5                 Pub  0.04
6              Market  0.03
7  Italian Restaurant  0.03
8         Pizza Place  0.03
9                Farm  0.02


---Blackheath, Westcombe Park---
                  venue  freq
0                   Pub  0.13
1                  Park  0.08
2         Grocery Store  0.05
3           Coffee Shop  0.05
4                Garden  0.03
5  Gym / Fitness Center  0.03
6    Italian Restaurant  0.03
7           Supermarket  0.03
8                Bakery  0.03
9         Historic Site  0.02


---Bloomsbury, Grays Inn---
                  venue  freq
0           Coffee Shop  0.10
1                Bakery  0.05
2                 Hotel  0.04
3               Theater  0.04
4              Beer Bar  0.03
5            Steakhouse  0.03
6           Pizza Place  0.03
7        Breakfast Spot  0.03
8             Bookstore  0.03
9  Gym / Fitness Center  0.03


---Bow, Bromley-by-Bow---
                venue  freq
0                 Pub  0.18
1                Café  0.10
2         Coffee Shop  0.06
3                Park  0.05
4         Art Gallery  0.04
5          Canal Lock  0.04
6          Restaurant  0.03
7  Turkish Restaurant  0.03
8                 Bar  0.03
9       Historic Site  0.02


---Brixton, Streatham Hill---
                  venue  freq
0           Coffee Shop  0.12
1                   Pub  0.07
2               Brewery  0.04
3            Restaurant  0.04
4          Cocktail Bar  0.04
5                Market  0.04
6  Caribbean Restaurant  0.03
7           Pizza Place  0.03
8                  Café  0.03
9                  Park  0.03


---Brockley, Crofton Park, Honor Oak Park---
                venue  freq
0                 Pub  0.13
1         Coffee Shop  0.13
2                Café  0.07
3                Park  0.06
4        Cocktail Bar  0.04
5                 Bar  0.04
6         Pizza Place  0.03
7           Gastropub  0.03
8  Italian Restaurant  0.03
9              Bakery  0.02


---Camberwell---
                       venue  freq
0                Coffee Shop  0.09
1                       Café  0.08
2                        Pub  0.07
3                       Park  0.06
4  Middle Eastern Restaurant  0.04
5                    Brewery  0.03
6         Italian Restaurant  0.03
7              Grocery Store  0.03
8               Cocktail Bar  0.03
9                Pizza Place  0.03


---Canning Town, North Woolwich, Docklands---
                venue  freq
0               Hotel  0.15
1         Coffee Shop  0.08
2                 Pub  0.07
3                Park  0.04
4       Grocery Store  0.04
5              Lounge  0.03
6  Chinese Restaurant  0.03
7                 Bar  0.03
8           Hotel Bar  0.02
9         Music Venue  0.02


---Catford, Hither Green, Bellingham---
                  venue  freq
0         Grocery Store  0.16
1           Supermarket  0.09
2                  Park  0.08
3                  Café  0.06
4                   Pub  0.05
5  Fast Food Restaurant  0.05
6    Italian Restaurant  0.05
7           Coffee Shop  0.05
8        Hardware Store  0.03
9         Train Station  0.03


---Charlton---
                    venue  freq
0                     Pub  0.11
1                    Park  0.08
2             Coffee Shop  0.06
3           Grocery Store  0.05
4          Clothing Store  0.03
5    Gym / Fitness Center  0.03
6             Supermarket  0.03
7                Bus Stop  0.03
8    Fast Food Restaurant  0.02
9  Furniture / Home Store  0.02


---Chelsea, Brompton---
                      venue  freq
0                     Hotel  0.10
1                      Café  0.06
2                     Plaza  0.05
3             Deli / Bodega  0.04
4            Ice Cream Shop  0.04
5               Coffee Shop  0.04
6      Gym / Fitness Center  0.03
7                       Pub  0.03
8                    Garden  0.03
9  Mediterranean Restaurant  0.03


---Chingford, Highams Park---
                  venue  freq
0                   Pub  0.13
1         Grocery Store  0.08
2           Coffee Shop  0.08
3                  Park  0.08
4           Supermarket  0.06
5                  Café  0.04
6   Sporting Goods Shop  0.04
7    Turkish Restaurant  0.04
8  Fast Food Restaurant  0.04
9                   Gym  0.04


---Chiswick---
                  venue  freq
0           Coffee Shop  0.12
1                   Pub  0.10
2                  Park  0.07
3                  Café  0.07
4         Grocery Store  0.06
5                Bakery  0.05
6  Gym / Fitness Center  0.04
7             Gastropub  0.04
8     French Restaurant  0.02
9   Japanese Restaurant  0.02


---Clapham---
                venue  freq
0                 Pub  0.08
1         Coffee Shop  0.06
2  Italian Restaurant  0.05
3         Pizza Place  0.04
4                Café  0.04
5              Market  0.04
6          Restaurant  0.04
7                Park  0.03
8              Bakery  0.03
9        Cocktail Bar  0.03


---Clapton---
                venue  freq
0                 Pub  0.11
1                Café  0.11
2         Coffee Shop  0.07
3                Park  0.06
4        Cocktail Bar  0.05
5  Turkish Restaurant  0.04
6                 Bar  0.03
7              Bakery  0.03
8      Breakfast Spot  0.03
9           Gastropub  0.02


---Clerkenwell, Finsbury, Barbican---
                   venue  freq
0            Coffee Shop  0.15
1                  Hotel  0.06
2   Gym / Fitness Center  0.04
3                    Pub  0.04
4           Cocktail Bar  0.04
5                   Café  0.03
6               Beer Bar  0.03
7                    Bar  0.03
8     Falafel Restaurant  0.03
9  Vietnamese Restaurant  0.02


---Covent Garden, Holborn, Strand---
            venue  freq
0           Hotel  0.06
1         Theater  0.06
2     Coffee Shop  0.05
3          Bakery  0.04
4           Plaza  0.04
5       Bookstore  0.04
6      Steakhouse  0.04
7          Garden  0.03
8  History Museum  0.03
9  Ice Cream Shop  0.03


---Cricklewood, Neasden---
                  venue  freq
0           Coffee Shop  0.09
1                  Café  0.07
2         Grocery Store  0.07
3           Supermarket  0.04
4                   Pub  0.04
5                 Hotel  0.04
6                  Park  0.04
7  Fast Food Restaurant  0.03
8                Bakery  0.03
9        Clothing Store  0.03


---Deptford---
                venue  freq
0                 Pub  0.13
1                Café  0.06
2         Coffee Shop  0.06
3                Park  0.04
4                 Bar  0.04
5              Garden  0.03
6        Cocktail Bar  0.03
7  Turkish Restaurant  0.02
8       Historic Site  0.02
9             Brewery  0.02


---Dulwich---
                  venue  freq
0                   Pub  0.14
1                  Café  0.09
2                  Park  0.06
3                Bakery  0.06
4           Coffee Shop  0.05
5         Grocery Store  0.05
6               Brewery  0.03
7    Italian Restaurant  0.03
8  Gym / Fitness Center  0.03
9        Farmers Market  0.03


---Ealing---
                  venue  freq
0           Coffee Shop  0.11
1                   Pub  0.09
2                  Park  0.07
3    Italian Restaurant  0.05
4           Pizza Place  0.04
5         Grocery Store  0.03
6          Burger Joint  0.03
7  Gym / Fitness Center  0.03
8                  Café  0.03
9           Supermarket  0.02


---Earls Court---
                  venue  freq
0    Italian Restaurant  0.06
1                 Hotel  0.05
2  Gym / Fitness Center  0.04
3           Coffee Shop  0.04
4                Bakery  0.04
5                  Café  0.04
6               Exhibit  0.03
7           Pizza Place  0.03
8     French Restaurant  0.03
9        Science Museum  0.03


---East Dulwich---
                  venue  freq
0                  Café  0.10
1                  Park  0.08
2           Pizza Place  0.07
3                   Pub  0.07
4           Coffee Shop  0.05
5    Italian Restaurant  0.05
6              Platform  0.03
7                Forest  0.03
8  Gym / Fitness Center  0.03
9         Grocery Store  0.03


---East Finchley---
                  venue  freq
0                  Café  0.14
1                   Pub  0.11
2  Gym / Fitness Center  0.05
3           Coffee Shop  0.04
4    Italian Restaurant  0.04
5                Forest  0.04
6                Bakery  0.03
7     Indian Restaurant  0.03
8   Japanese Restaurant  0.03
9     French Restaurant  0.02


---East Ham---
                    venue  freq
0           Grocery Store  0.11
1             Supermarket  0.08
2       Indian Restaurant  0.07
3             Coffee Shop  0.07
4                   Hotel  0.06
5    Fast Food Restaurant  0.06
6          Discount Store  0.04
7  Furniture / Home Store  0.04
8                     Pub  0.04
9                    Park  0.04


---Eltham, Mottingham---
                      venue  freq
0             Grocery Store  0.11
1      Fast Food Restaurant  0.09
2                      Park  0.07
3               Pizza Place  0.05
4                       Pub  0.05
5                       Gym  0.04
6              Soccer Field  0.04
7         Convenience Store  0.04
8  Mediterranean Restaurant  0.04
9                  Pharmacy  0.04


---Finchley Central---
                  venue  freq
0         Grocery Store  0.08
1                Bakery  0.08
2           Supermarket  0.08
3  Gym / Fitness Center  0.06
4    Turkish Restaurant  0.06
5                   Pub  0.06
6                  Café  0.05
7    Italian Restaurant  0.05
8                  Park  0.03
9   Japanese Restaurant  0.03


---Finsbury Park, Manor House---
                  venue  freq
0                  Café  0.13
1                   Pub  0.11
2    Turkish Restaurant  0.09
3    Italian Restaurant  0.05
4           Coffee Shop  0.04
5      Tapas Restaurant  0.03
6                  Park  0.03
7           Pizza Place  0.03
8                Bakery  0.03
9  Gym / Fitness Center  0.03


---Fleet Street, St. Pauls---
                  venue  freq
0               Theater  0.09
1                 Hotel  0.09
2           Coffee Shop  0.07
3  Gym / Fitness Center  0.04
4              Beer Bar  0.03
5        Scenic Lookout  0.03
6           Art Gallery  0.03
7            Art Museum  0.03
8             Roof Deck  0.02
9        History Museum  0.02


---Forest Gate, Upton Park---
                  venue  freq
0         Grocery Store  0.14
1                   Pub  0.12
2     Indian Restaurant  0.10
3  Fast Food Restaurant  0.05
4                  Park  0.04
5            Restaurant  0.03
6           Coffee Shop  0.03
7                  Café  0.03
8                 Hotel  0.03
9                Bakery  0.02


---Forest Hill---
                  venue  freq
0                   Pub  0.16
1           Coffee Shop  0.08
2                  Café  0.06
3           Supermarket  0.06
4                  Park  0.05
5         Grocery Store  0.05
6  Gym / Fitness Center  0.03
7     Indian Restaurant  0.02
8              Pharmacy  0.02
9                Forest  0.02


---Friern Barnet, New Southgate---
                venue  freq
0       Grocery Store  0.12
1                 Pub  0.09
2         Coffee Shop  0.08
3                Café  0.08
4                Park  0.05
5         Pizza Place  0.03
6    Greek Restaurant  0.03
7  Italian Restaurant  0.02
8   Indian Restaurant  0.02
9        Dessert Shop  0.02


---Fulham, Parsons Green---
             venue  freq
0             Café  0.12
1      Coffee Shop  0.09
2             Park  0.08
3      Pizza Place  0.06
4              Pub  0.04
5  Thai Restaurant  0.03
6        Gastropub  0.02
7           Bakery  0.02
8   Soccer Stadium  0.02
9      Supermarket  0.02


---Golders Green, Hampstead Gdn Suburb---
                venue  freq
0       Grocery Store  0.11
1         Coffee Shop  0.10
2                Café  0.07
3                Park  0.06
4              Bakery  0.05
5         Supermarket  0.04
6   Korean Restaurant  0.03
7               Hotel  0.03
8  Turkish Restaurant  0.03
9    Sushi Restaurant  0.03


---Greenwich---
                    venue  freq
0                     Pub  0.13
1                    Park  0.06
2           Grocery Store  0.05
3                    Café  0.04
4                  Garden  0.04
5                     Bar  0.03
6          Scenic Lookout  0.02
7       French Restaurant  0.02
8  Furniture / Home Store  0.02
9           Historic Site  0.02


---Hackney, Dalston---
         venue  freq
0          Pub  0.10
1  Coffee Shop  0.09
2       Bakery  0.07
3         Café  0.06
4    Bookstore  0.04
5         Park  0.04
6      Brewery  0.03
7    Wine Shop  0.03
8  Pizza Place  0.03
9    Roof Deck  0.02


---Hackney, Homerton---
          venue  freq
0           Pub  0.15
1   Coffee Shop  0.12
2          Café  0.07
3        Bakery  0.06
4   Pizza Place  0.04
5     Bookstore  0.03
6          Park  0.03
7         Canal  0.02
8  Cocktail Bar  0.02
9     Wine Shop  0.02


---Hammersmith---
                       venue  freq
0                        Pub  0.12
1                Coffee Shop  0.08
2                       Café  0.07
3         Italian Restaurant  0.04
4              Grocery Store  0.03
5                       Park  0.03
6                  Gastropub  0.03
7  Middle Eastern Restaurant  0.03
8                Pizza Place  0.03
9             Clothing Store  0.02


---Hampstead, Swiss Cottage---
            venue  freq
0            Café  0.11
1             Pub  0.08
2            Park  0.05
3          Bakery  0.05
4     Coffee Shop  0.04
5       Gastropub  0.04
6   Deli / Bodega  0.03
7  History Museum  0.03
8     Pizza Place  0.03
9       Bookstore  0.03


---Hanwell---
                venue  freq
0                 Pub  0.11
1                Park  0.10
2               Hotel  0.05
3                 Gym  0.03
4  Persian Restaurant  0.03
5                Café  0.03
6       Grocery Store  0.03
7   Indian Restaurant  0.03
8       Train Station  0.03
9             Brewery  0.03


---Hendon, Brent Cross---
                  venue  freq
0         Grocery Store  0.09
1           Coffee Shop  0.08
2                  Café  0.05
3           Supermarket  0.05
4  Gym / Fitness Center  0.05
5           Pizza Place  0.04
6                   Pub  0.04
7                 Hotel  0.04
8      Asian Restaurant  0.03
9                  Park  0.03


---Herne Hill---
                           venue  freq
0                    Coffee Shop  0.09
1                            Pub  0.08
2                           Café  0.06
3                           Park  0.04
4                        Brewery  0.04
5                    Pizza Place  0.04
6                   Cocktail Bar  0.04
7                         Market  0.04
8                         Bakery  0.03
9  Vegetarian / Vegan Restaurant  0.03


---Highbury---
                  venue  freq
0                   Pub  0.11
1                  Café  0.10
2           Coffee Shop  0.08
3                  Park  0.05
4  Ethiopian Restaurant  0.03
5           Pizza Place  0.03
6         Deli / Bodega  0.03
7                Bakery  0.03
8    Seafood Restaurant  0.02
9  Gym / Fitness Center  0.02


---Highgate---
                venue  freq
0                 Pub  0.22
1                Café  0.10
2         Coffee Shop  0.06
3  Italian Restaurant  0.05
4           Gastropub  0.04
5                Park  0.04
6              Bakery  0.04
7         Pizza Place  0.03
8   Indian Restaurant  0.02
9               Trail  0.02


---Holloway---
                  venue  freq
0                   Pub  0.11
1                  Café  0.09
2           Coffee Shop  0.07
3                  Park  0.05
4    Italian Restaurant  0.04
5           Pizza Place  0.03
6             Wine Shop  0.03
7               Theater  0.03
8  Ethiopian Restaurant  0.03
9          Liquor Store  0.02


---Hornsey, Crouch End---
                 venue  freq
0                 Café  0.13
1                  Pub  0.09
2   Turkish Restaurant  0.08
3          Coffee Shop  0.06
4               Bakery  0.05
5  Japanese Restaurant  0.04
6                 Park  0.04
7          Pizza Place  0.03
8                Trail  0.03
9        Grocery Store  0.03


---Islington, Barnsbury, Canonbury---
                   venue  freq
0            Coffee Shop  0.11
1                    Pub  0.06
2                 Bakery  0.04
3                   Café  0.04
4             Restaurant  0.04
5           Cocktail Bar  0.03
6        Organic Grocery  0.03
7     Italian Restaurant  0.03
8  Vietnamese Restaurant  0.03
9             Bagel Shop  0.02


---Kensington---
                venue  freq
0               Hotel  0.07
1              Garden  0.05
2                Café  0.04
3                 Pub  0.03
4             Exhibit  0.03
5   Indian Restaurant  0.03
6         Coffee Shop  0.03
7          Restaurant  0.03
8  Italian Restaurant  0.03
9              Bakery  0.03


---Kentish Town---
               venue  freq
0                Pub  0.16
1        Coffee Shop  0.06
2             Bakery  0.05
3          Gastropub  0.05
4               Café  0.05
5     Ice Cream Shop  0.03
6        Pizza Place  0.03
7      Deli / Bodega  0.02
8  French Restaurant  0.02
9             Market  0.02


---Kinsbury, Colindale---
                  venue  freq
0           Supermarket  0.07
1           Coffee Shop  0.06
2         Grocery Store  0.06
3                  Café  0.05
4  Gym / Fitness Center  0.05
5                  Park  0.04
6                   Pub  0.04
7           Pizza Place  0.04
8      Asian Restaurant  0.03
9    Chinese Restaurant  0.03


---Ladbroke Grove, North Kensington---
                  venue  freq
0                   Pub  0.07
1  Gym / Fitness Center  0.06
2            Restaurant  0.05
3                Bakery  0.05
4           Pizza Place  0.04
5                   Bar  0.03
6           Coffee Shop  0.03
7                  Café  0.03
8    Italian Restaurant  0.03
9                  Park  0.03


---Lambeth---
                venue  freq
0                Café  0.10
1                 Pub  0.08
2         Coffee Shop  0.06
3                Park  0.05
4               Hotel  0.04
5             Theater  0.03
6  Italian Restaurant  0.03
7              Garden  0.03
8      Farmers Market  0.02
9             Gay Bar  0.02


---Lee, Grove Park---
                  venue  freq
0         Grocery Store  0.15
1                   Pub  0.13
2                  Park  0.13
3                  Café  0.07
4    Italian Restaurant  0.05
5           Supermarket  0.04
6           Coffee Shop  0.04
7              Platform  0.04
8         Train Station  0.04
9  Gym / Fitness Center  0.04


---Lewisham, Hither Green---
                  venue  freq
0                   Pub  0.13
1                  Café  0.08
2                  Park  0.07
3             Gastropub  0.05
4                Garden  0.04
5            Food Truck  0.03
6            Restaurant  0.03
7  Gym / Fitness Center  0.03
8           Supermarket  0.03
9           Coffee Shop  0.03


---Leyton---
                      venue  freq
0                       Pub  0.12
1                      Café  0.09
2               Coffee Shop  0.04
3                Restaurant  0.04
4                      Park  0.04
5            Clothing Store  0.02
6                 Juice Bar  0.02
7  Mediterranean Restaurant  0.02
8         Fish & Chips Shop  0.02
9                  Beer Bar  0.02


---Leytonstone---
                      venue  freq
0                       Pub  0.16
1                      Café  0.11
2             Grocery Store  0.08
3                      Park  0.08
4               Coffee Shop  0.05
5  Mediterranean Restaurant  0.05
6               Pizza Place  0.05
7                Restaurant  0.05
8                    Bakery  0.05
9         Convenience Store  0.03


---Lower Edmonton---
                  venue  freq
0    Turkish Restaurant  0.11
1         Grocery Store  0.08
2                 Hotel  0.06
3                   Pub  0.06
4  Fast Food Restaurant  0.06
5           Supermarket  0.06
6           Coffee Shop  0.06
7                  Park  0.03
8           Sports Club  0.03
9         Train Station  0.03


---Maida Vale, Warwick Avenue---
                  venue  freq
0                   Pub  0.08
1                Bakery  0.07
2           Pizza Place  0.06
3                  Café  0.05
4            Restaurant  0.04
5    Italian Restaurant  0.03
6                   Gym  0.03
7                   Bar  0.03
8  Gym / Fitness Center  0.03
9    Turkish Restaurant  0.03


---Manor Park---
                  venue  freq
0         Grocery Store  0.12
1     Indian Restaurant  0.09
2  Fast Food Restaurant  0.08
3        Clothing Store  0.06
4           Coffee Shop  0.05
5                Bakery  0.05
6        Sandwich Place  0.04
7                   Pub  0.04
8                  Park  0.04
9           Supermarket  0.04


---Mayfair, Marylebone, Soho---
               venue  freq
0              Hotel  0.08
1          Juice Bar  0.06
2  French Restaurant  0.05
3        Coffee Shop  0.05
4          Hotel Bar  0.04
5             Bakery  0.03
6        Art Gallery  0.03
7      Movie Theater  0.03
8     Clothing Store  0.03
9       Burger Joint  0.03


---Mill Hill---
                venue  freq
0  Italian Restaurant  0.09
1       Grocery Store  0.09
2         Golf Course  0.06
3            Platform  0.06
4                 Pub  0.06
5       Train Station  0.03
6               Hotel  0.03
7                 Spa  0.03
8      History Museum  0.03
9         Coffee Shop  0.03


---Monument, Tower Hill, Aldgate---
                  venue  freq
0           Coffee Shop  0.13
1                 Hotel  0.09
2  Gym / Fitness Center  0.03
3         Grocery Store  0.03
4    Italian Restaurant  0.03
5          Cocktail Bar  0.02
6          Burger Joint  0.02
7                Bakery  0.02
8    Seafood Restaurant  0.02
9           Pizza Place  0.02


---Moorgate, Liverpool Street---
                   venue  freq
0            Coffee Shop  0.13
1                  Hotel  0.08
2   Gym / Fitness Center  0.06
3           Cocktail Bar  0.04
4             Restaurant  0.03
5     Italian Restaurant  0.03
6      Indian Restaurant  0.02
7  Vietnamese Restaurant  0.02
8            Pizza Place  0.02
9                 Garden  0.02


---Mortlake, East Sheen---
               venue  freq
0                Pub  0.13
1        Coffee Shop  0.08
2      Grocery Store  0.06
3               Café  0.05
4               Park  0.05
5        Pizza Place  0.04
6     Farmers Market  0.04
7     Clothing Store  0.03
8         Restaurant  0.03
9  French Restaurant  0.03


---Muswell Hill---
                 venue  freq
0                  Pub  0.13
1                 Café  0.13
2          Coffee Shop  0.07
3    Indian Restaurant  0.04
4  Japanese Restaurant  0.04
5        Grocery Store  0.03
6               Forest  0.03
7                 Park  0.03
8   Italian Restaurant  0.03
9        Deli / Bodega  0.03


---New Cross, New Cross Gate---
                  venue  freq
0                   Pub  0.13
1           Coffee Shop  0.09
2                  Café  0.06
3    Italian Restaurant  0.04
4                   Bar  0.04
5               Brewery  0.03
6          Cocktail Bar  0.03
7                  Park  0.03
8           Pizza Place  0.03
9  Gym / Fitness Center  0.03


---North Finchley, Woodside Park---
                venue  freq
0         Coffee Shop  0.11
1         Supermarket  0.06
2                Café  0.06
3  Turkish Restaurant  0.05
4  Italian Restaurant  0.05
5       Grocery Store  0.05
6   Indian Restaurant  0.04
7            Pharmacy  0.04
8                 Pub  0.04
9      Sandwich Place  0.03


---Notting Hill, Holland Park---
                  venue  freq
0                   Pub  0.05
1                Bakery  0.05
2  Gym / Fitness Center  0.04
3    Italian Restaurant  0.04
4           Pizza Place  0.04
5            Restaurant  0.03
6                Garden  0.03
7        Cosmetics Shop  0.02
8           Supermarket  0.02
9             Bookstore  0.02


---Olympic Park---
                venue  freq
0                Café  0.09
1                 Pub  0.08
2                Park  0.06
3         Art Gallery  0.04
4         Coffee Shop  0.03
5  Italian Restaurant  0.03
6      Clothing Store  0.02
7             Brewery  0.02
8          Restaurant  0.02
9              Bistro  0.02


---Palmers Green---
                venue  freq
0                 Pub  0.09
1         Coffee Shop  0.08
2       Grocery Store  0.08
3    Greek Restaurant  0.06
4                Park  0.05
5  Italian Restaurant  0.04
6                Café  0.03
7            Bus Stop  0.03
8         Supermarket  0.03
9         Pizza Place  0.03


---Peckham, Nunhead---
                 venue  freq
0                  Pub  0.12
1                 Café  0.06
2                 Park  0.06
3          Pizza Place  0.06
4                  Bar  0.04
5          Coffee Shop  0.04
6            Gastropub  0.04
7  Indie Movie Theater  0.03
8         Cocktail Bar  0.03
9   Italian Restaurant  0.03


---Penge, Anerley---
                  venue  freq
0                   Pub  0.11
1                  Café  0.07
2           Supermarket  0.06
3           Coffee Shop  0.06
4           Pizza Place  0.05
5         Grocery Store  0.05
6                  Park  0.05
7    Italian Restaurant  0.04
8             Gastropub  0.04
9  Gym / Fitness Center  0.04


---Plaistow---
                  venue  freq
0         Grocery Store  0.12
1                   Pub  0.08
2  Fast Food Restaurant  0.06
3              Platform  0.05
4           Coffee Shop  0.05
5                  Café  0.04
6        Sandwich Place  0.04
7                  Park  0.04
8      Asian Restaurant  0.03
9                Bakery  0.03


---Poplar, Millwall, Isle of Dogs, Docklands---
                  venue  freq
0                   Pub  0.07
1           Coffee Shop  0.07
2                 Hotel  0.06
3                  Park  0.04
4                 Plaza  0.03
5    Italian Restaurant  0.03
6                   Bar  0.03
7          Burger Joint  0.03
8     Indian Restaurant  0.03
9  Gym / Fitness Center  0.03


---Putney, Roehampton---
                   venue  freq
0                    Pub  0.14
1            Coffee Shop  0.09
2                   Park  0.08
3                   Café  0.07
4     Italian Restaurant  0.04
5                    Bar  0.04
6   Gym / Fitness Center  0.03
7      Indian Restaurant  0.03
8  Portuguese Restaurant  0.03
9                    Gym  0.02


---Regents Park, Camden Town---
               venue  freq
0               Café  0.05
1        Coffee Shop  0.05
2             Garden  0.03
3      Grocery Store  0.03
4                Pub  0.03
5  French Restaurant  0.03
6                Bar  0.03
7        Music Venue  0.03
8             Market  0.03
9               Park  0.02


---Rotherhithe, South Bermonsey, Surrey Docks---
         venue  freq
0          Pub  0.11
1         Park  0.08
2      Brewery  0.07
3  Coffee Shop  0.06
4          Bar  0.05
5     Beer Bar  0.04
6        Trail  0.03
7   Food Truck  0.03
8         Café  0.03
9   Restaurant  0.02


---Seven Sisters---
                venue  freq
0  Turkish Restaurant  0.13
1                Café  0.10
2                 Pub  0.09
3         Coffee Shop  0.05
4                Park  0.05
5              Bakery  0.04
6                 Gym  0.03
7                 Bar  0.03
8              Lounge  0.02
9  Italian Restaurant  0.02


---Shepherds Bush---
                       venue  freq
0                        Pub  0.07
1                       Café  0.06
2          Indian Restaurant  0.05
3  Middle Eastern Restaurant  0.04
4                Coffee Shop  0.04
5                  Gastropub  0.04
6                     Bakery  0.04
7                Pizza Place  0.04
8        Japanese Restaurant  0.03
9                       Park  0.03


---South Kensington---
                      venue  freq
0                     Hotel  0.09
1                      Café  0.07
2            Ice Cream Shop  0.05
3        Italian Restaurant  0.04
4  Mediterranean Restaurant  0.03
5                   Exhibit  0.03
6         French Restaurant  0.03
7                Restaurant  0.03
8                    Bakery  0.03
9         Indian Restaurant  0.03


---South Lambeth, Nine Elms---
                  venue  freq
0                  Café  0.09
1           Coffee Shop  0.08
2                   Pub  0.06
3                  Park  0.05
4                Bakery  0.04
5           Supermarket  0.03
6            Restaurant  0.03
7  Gym / Fitness Center  0.03
8         Deli / Bodega  0.03
9             Gastropub  0.03


---South Norwood---
                         venue  freq
0                Grocery Store  0.13
1                          Pub  0.09
2                     Platform  0.07
3                  Supermarket  0.07
4                  Coffee Shop  0.06
5                         Park  0.06
6                Train Station  0.04
7                 Tram Station  0.04
8                         Café  0.04
9  Eastern European Restaurant  0.02


---South Wimbledon, Raynes Park---
                  venue  freq
0                   Pub  0.11
1           Coffee Shop  0.06
2         Grocery Store  0.05
3                  Park  0.05
4                Bakery  0.03
5                   Bar  0.03
6      Sushi Restaurant  0.03
7                  Café  0.03
8  Gym / Fitness Center  0.03
9          Burger Joint  0.03


---South Woodford---
                venue  freq
0                 Pub  0.07
1       Grocery Store  0.07
2                Café  0.06
3         Coffee Shop  0.06
4  Italian Restaurant  0.05
5                Park  0.04
6          Restaurant  0.04
7         Supermarket  0.04
8       Metro Station  0.04
9  English Restaurant  0.04


---Southgate---
                  venue  freq
0                   Pub  0.08
1         Grocery Store  0.08
2                  Café  0.06
3                  Park  0.06
4    Italian Restaurant  0.05
5           Coffee Shop  0.05
6  Gym / Fitness Center  0.05
7          Tennis Court  0.03
8     Fish & Chips Shop  0.03
9           Pizza Place  0.03


---St Johns Wood---
                venue  freq
0                Café  0.10
1         Zoo Exhibit  0.05
2                 Pub  0.04
3         Coffee Shop  0.04
4              Garden  0.04
5   French Restaurant  0.04
6              Bakery  0.03
7             Theater  0.03
8  Athletics & Sports  0.03
9            Wine Bar  0.02


---Stockwell, Brixton---
                   venue  freq
0            Coffee Shop  0.12
1                   Café  0.09
2                    Pub  0.08
3           Cocktail Bar  0.04
4                   Park  0.04
5                 Market  0.03
6            Pizza Place  0.03
7  Portuguese Restaurant  0.02
8      Indian Restaurant  0.02
9                Brewery  0.02


---Stoke Newington, Stamford Hill---
                venue  freq
0                 Pub  0.12
1                Café  0.12
2        Cocktail Bar  0.04
3      Breakfast Spot  0.04
4  Turkish Restaurant  0.04
5                Park  0.04
6         Coffee Shop  0.04
7         Pizza Place  0.03
8              Bakery  0.03
9     Organic Grocery  0.02


---Stratford, West Ham---
               venue  freq
0                Pub  0.11
1               Café  0.07
2      Grocery Store  0.05
3               Park  0.05
4        Art Gallery  0.04
5        Coffee Shop  0.04
6              Hotel  0.02
7         Restaurant  0.02
8  Fish & Chips Shop  0.02
9            Brewery  0.02


---Streatham, Norbury---
            venue  freq
0             Pub  0.12
1   Grocery Store  0.11
2            Café  0.09
3     Supermarket  0.06
4     Coffee Shop  0.04
5            Park  0.04
6     Pizza Place  0.03
7        Pharmacy  0.03
8  Breakfast Spot  0.03
9             Bar  0.02


---Sydenham---
                  venue  freq
0                   Pub  0.14
1           Coffee Shop  0.09
2                  Café  0.06
3           Pizza Place  0.05
4           Supermarket  0.04
5  Gym / Fitness Center  0.04
6    Italian Restaurant  0.04
7                  Park  0.03
8         Train Station  0.03
9             Gastropub  0.03


---Thamesmead---
                  venue  freq
0           Supermarket  0.14
1       Warehouse Store  0.10
2  Fast Food Restaurant  0.10
3         Grocery Store  0.10
4        Clothing Store  0.05
5         Historic Site  0.05
6              Pharmacy  0.05
7     Mobile Phone Shop  0.05
8         Train Station  0.05
9     Food & Drink Shop  0.05


---Tooting---
                venue  freq
0                 Pub  0.17
1         Coffee Shop  0.12
2                Café  0.07
3   Indian Restaurant  0.05
4  Italian Restaurant  0.05
5        Cocktail Bar  0.04
6                 Bar  0.04
7         Pizza Place  0.03
8   French Restaurant  0.03
9   Fish & Chips Shop  0.03


---Tottenham---
                  venue  freq
0                   Pub  0.13
1           Coffee Shop  0.09
2                  Park  0.05
3    Turkish Restaurant  0.04
4  Fast Food Restaurant  0.04
5         Grocery Store  0.04
6           Supermarket  0.04
7           Pizza Place  0.03
8         Train Station  0.03
9                   Bar  0.03


---Upper Edmonton---
                  venue  freq
0                   Pub  0.10
1           Coffee Shop  0.09
2           Supermarket  0.08
3    Turkish Restaurant  0.06
4                  Park  0.05
5                  Café  0.05
6           Pizza Place  0.04
7                 Hotel  0.04
8                Bakery  0.03
9  Fast Food Restaurant  0.03


---Upper Norwood, Crystal Palace---
                venue  freq
0                 Pub  0.12
1         Coffee Shop  0.07
2                Park  0.06
3  Italian Restaurant  0.05
4                Café  0.05
5       Train Station  0.04
6           Gastropub  0.03
7              Bakery  0.03
8       Grocery Store  0.03
9       Movie Theater  0.02


---Walthamstow---
                  venue  freq
0                   Pub  0.11
1           Coffee Shop  0.07
2         Grocery Store  0.07
3           Supermarket  0.05
4                  Café  0.05
5               Brewery  0.04
6           Pizza Place  0.04
7  Gym / Fitness Center  0.03
8            Restaurant  0.03
9        Clothing Store  0.02


---Walworth, Elephant & Castle---
                venue  freq
0         Coffee Shop  0.11
1                 Pub  0.08
2                Café  0.07
3                Park  0.05
4  Italian Restaurant  0.04
5               Hotel  0.03
6         Pizza Place  0.03
7         Art Gallery  0.03
8             Theater  0.03
9               Plaza  0.02


---Wandsworth, Earlsfield---
               venue  freq
0                Pub  0.17
1        Coffee Shop  0.11
2               Café  0.08
3        Pizza Place  0.04
4               Park  0.04
5                Bar  0.04
6  French Restaurant  0.04
7    Thai Restaurant  0.04
8       Cocktail Bar  0.03
9        Supermarket  0.02


---Wapping---
                  venue  freq
0           Coffee Shop  0.15
1                 Hotel  0.08
2                   Pub  0.06
3      Tapas Restaurant  0.03
4          Cocktail Bar  0.03
5               Brewery  0.03
6  Gym / Fitness Center  0.03
7                Garden  0.03
8                Bakery  0.03
9         Deli / Bodega  0.03


---Waterloo, Bermondsey, Southwark, Borough---
                   venue  freq
0            Coffee Shop  0.16
1                  Hotel  0.06
2                Theater  0.05
3                    Pub  0.05
4           Burger Joint  0.03
5          Grocery Store  0.03
6  Street Food Gathering  0.03
7         Scenic Lookout  0.03
8          Deli / Bodega  0.03
9                   Park  0.02


---West Brompton, Worlds End---
                  venue  freq
0                Bakery  0.07
1     French Restaurant  0.04
2           Coffee Shop  0.04
3  Gym / Fitness Center  0.04
4    Italian Restaurant  0.04
5                  Café  0.04
6        Ice Cream Shop  0.04
7                 Hotel  0.04
8               Exhibit  0.03
9                Garden  0.03


---West Ealing---
                venue  freq
0                 Pub  0.12
1                Park  0.09
2         Coffee Shop  0.08
3                Café  0.05
4  Italian Restaurant  0.04
5               Hotel  0.04
6         Pizza Place  0.03
7        Burger Joint  0.03
8      Sandwich Place  0.02
9         Supermarket  0.02


---West Hampstead, Kilburn, Queens Park---
                       venue  freq
0                        Pub  0.09
1                       Café  0.09
2                     Bakery  0.06
3                Coffee Shop  0.04
4                Pizza Place  0.04
5  Middle Eastern Restaurant  0.03
6              Deli / Bodega  0.03
7       Gym / Fitness Center  0.03
8               Burger Joint  0.02
9       Brazilian Restaurant  0.02


---West Kensington---
                venue  freq
0                Café  0.07
1         Coffee Shop  0.05
2         Pizza Place  0.05
3           Gastropub  0.04
4                 Pub  0.04
5              Bakery  0.03
6  Italian Restaurant  0.03
7                Park  0.03
8               Hotel  0.02
9     Thai Restaurant  0.02


---West Norwood, Tulse Hill---
                  venue  freq
0                   Pub  0.13
1           Coffee Shop  0.09
2         Grocery Store  0.08
3                  Café  0.06
4                Bakery  0.04
5                  Park  0.04
6  Gym / Fitness Center  0.03
7              Pharmacy  0.03
8           Supermarket  0.03
9               Brewery  0.03


---Westminster, Belgravia, Pimlico---
                      venue  freq
0                     Hotel  0.12
1                     Plaza  0.08
2                      Café  0.06
3                      Park  0.05
4                Art Museum  0.04
5                  Boutique  0.04
6                 Gastropub  0.03
7  Mediterranean Restaurant  0.03
8               Coffee Shop  0.03
9                    Garden  0.03


---Whetstone, Totteridge---
                  venue  freq
0           Coffee Shop  0.14
1                   Pub  0.09
2         Grocery Store  0.06
3                  Café  0.05
4           Supermarket  0.05
5              Pharmacy  0.04
6  Fast Food Restaurant  0.04
7                  Park  0.04
8     Fish & Chips Shop  0.04
9    Italian Restaurant  0.03


---Whitechapel, Stepney, Mile End---
                venue  freq
0         Coffee Shop  0.13
1                Café  0.07
2          Restaurant  0.05
3               Hotel  0.04
4                 Pub  0.04
5        Cocktail Bar  0.04
6         Pizza Place  0.03
7  Italian Restaurant  0.03
8  Turkish Restaurant  0.03
9                Farm  0.03


---Willesden, Harlesden, Kensal Green---
                       venue  freq
0                       Café  0.09
1                Pizza Place  0.06
2                Coffee Shop  0.06
3              Grocery Store  0.06
4                        Pub  0.05
5  Middle Eastern Restaurant  0.05
6       Fast Food Restaurant  0.04
7            Thai Restaurant  0.03
8                 Hookah Bar  0.03
9                      Hotel  0.03


---Wimbledon, Merton---
              venue  freq
0               Pub  0.08
1              Park  0.07
2  Sushi Restaurant  0.05
3      Tennis Court  0.05
4              Café  0.03
5    Tennis Stadium  0.03
6   Thai Restaurant  0.03
7     Grocery Store  0.03
8               Bar  0.03
9      Burger Joint  0.03


---Winchmore Hill---
                venue  freq
0                 Pub  0.08
1         Supermarket  0.08
2                Park  0.08
3       Grocery Store  0.07
4         Pizza Place  0.07
5      Clothing Store  0.05
6       Train Station  0.03
7              Bakery  0.03
8         Sports Club  0.03
9  Italian Restaurant  0.03


---Wood Green, Alexandra Palace---
                      venue  freq
0                       Pub  0.09
1                      Café  0.07
2             Grocery Store  0.07
3                      Park  0.05
4         Indian Restaurant  0.04
5  Mediterranean Restaurant  0.04
6               Coffee Shop  0.04
7          Greek Restaurant  0.04
8                    Bakery  0.03
9        Turkish Restaurant  0.03


---Woolwich, Plumstead---
            venue  freq
0   Grocery Store  0.10
1             Pub  0.10
2  Clothing Store  0.04
3          Bakery  0.04
4            Park  0.04
5     Coffee Shop  0.04
6     Supermarket  0.04
7           Hotel  0.03
8            Café  0.03
9   Train Station  0.03


The next step will consist in printing each district with the top 10 most common venues and creating a function to sort the venues in descending order.

In [40]:
# This function sort the london venues in descending order
def return_most_common_venues(row, num_top_venues):
    row_categories = row.iloc[1:]
    row_categories_sorted = row_categories.sort_values(ascending=False)
    
    return row_categories_sorted.index.values[0:num_top_venues]

Now let's create the new DataFrame and display the top 10 venues for each district.

In [41]:
num_top_venues = 10

indicators = ['st', 'nd', 'rd']

# creating columns according to number of top venues
columns = ['District']
for ind in np.arange(num_top_venues):
    try:
        columns.append('{}{} Most Common Venue'.format(ind+1, indicators[ind]))
    except:
        columns.append('{}th Most Common Venue'.format(ind+1))

# creating a new DataFrame
districts_venues_sorted = pd.DataFrame(columns=columns)
districts_venues_sorted['District'] = london_grouped['District']

for ind in np.arange(london_grouped.shape[0]):
    districts_venues_sorted.iloc[ind, 1:] = return_most_common_venues(london_grouped.iloc[ind, :], num_top_venues)
    
districts_venues_sorted.head()
Out [41]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 Abbey Wood Supermarket Grocery Store Fast Food Restaurant Lake Train Station Trail Eastern European Restaurant Pharmacy Platform Warehouse Store
1 Acton Coffee Shop Grocery Store Pub Gym / Fitness Center Hotel Middle Eastern Restaurant Park Hookah Bar Bakery Gastropub
2 Archway, Tufnell Park Pub Coffee Shop Café Pizza Place Bakery Italian Restaurant Gastropub Japanese Restaurant Trail Park
3 Balham Pub Coffee Shop Park French Restaurant Italian Restaurant Bakery Pizza Place Café Bar Burger Joint
4 Barnes, Castelnau Pub Park Café Coffee Shop Gastropub Farmers Market Restaurant Grocery Store Italian Restaurant Historic Site

Word clouds are commonly used to perform high-level analysis and visualization of text data and will be applied below to find the most common venues in London city using the previous DataFrame districts_venues_sorted, still sorted by district, in a powerful image using WordCloud library.

In [42]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
text = districts_venues_sorted

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

5.2. Clustering Districts

The following section consists in running k-means to cluster the district into 5 clusters. The k-means clustering method is an unsupervised machine learning technique used to identify clusters of data objects in a dataset.

In [43]:
# Setting the number of clusters
kclusters = 5

london_grouped_clustering = london_grouped.drop('District', 1)

# Running k-means clustering
kmeans = KMeans(n_clusters=kclusters, random_state=0).fit(london_grouped_clustering)

# Checking cluster labels generated for each row in the DataFrame
kmeans.labels_[0:10]
Out [43]:
array([4, 1, 2, 2, 2, 0, 3, 3, 2, 3])

Let's create a new DataFrame that includes the cluster as well as the top 10 venues for each district.

In [44]:
# Adding clustering labels
districts_venues_sorted.insert(0, 'Cluster Labels', kmeans.labels_)

london_merged = df_PCLondon

# Merging london_grouped with df to add latitude/longitude for each district
london_merged = london_merged.join(districts_venues_sorted.set_index('District'), on='District')

# Checking the last columns
london_merged.head()
Out [44]:
Postal Code District Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 E1 Whitechapel, Stepney, Mile End 51.520220 -0.054310 3 Coffee Shop Café Restaurant Pub Cocktail Bar Hotel Farm Italian Restaurant Turkish Restaurant Pizza Place
1 E1W Wapping 51.506282 -0.069426 3 Coffee Shop Hotel Pub Gym / Fitness Center Deli / Bodega French Restaurant Garden Tapas Restaurant Cocktail Bar Brewery
2 E2 Bethnal Green, Shoreditch 51.526690 -0.062570 3 Coffee Shop Bakery Café Pub Bookstore Restaurant Pizza Place Market Italian Restaurant Flea Market
3 E3 Bow, Bromley-by-Bow 51.527020 -0.025940 2 Pub Café Coffee Shop Park Art Gallery Canal Lock Restaurant Turkish Restaurant Bar Wine Shop
4 E4 Chingford, Highams Park 51.617800 -0.009340 2 Pub Coffee Shop Grocery Store Park Supermarket Sporting Goods Shop Turkish Restaurant Café Fast Food Restaurant Gym

The resulting clusters will be visualized using Folium library.

In [45]:
# Creating the map with folium library
map_clusters = folium.Map(location=[latitude, longitude], zoom_start=11)

# Setting color scheme for the clusters
x = np.arange(kclusters)
ys = [i + x + (i*x)**2 for i in range(kclusters)]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]

london_merged_nonan = london_merged.dropna(subset=['Cluster Labels'])

# Adding markers to the map
markers_colors = []
for lat, lon, poi, cluster in zip(london_merged_nonan['Latitude'], london_merged_nonan['Longitude'], london_merged_nonan['District'], london_merged_nonan['Cluster Labels']):
    label = folium.Popup(str(poi) + ' Cluster ' + str(cluster), parse_html=True)
    folium.CircleMarker(
        [lat, lon],
        radius=8,
        popup=label,
        color=rainbow[cluster-1],
        fill=True,
        fill_color=rainbow[cluster-1],
        fill_opacity=0.8).add_to(map_clusters)
    
map_clusters
Out [45]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Remarks: Click on the markers to see the district and the corresponding cluster. Here below, each cluster is presented with its corresponding color.

  • Cluster 0: Red color (London north and south periphery)
  • Cluster 1: Purple color (London north outskirts)
  • Cluster 2: Light Blue color (London center and south)
  • Cluster 3: Light Green color (London center and center-east)
  • Cluster 4: Light Orange color (London east outskirts)

5.3. Examining the Clusters

Each cluster will be examined and set the discriminating venue categories that distinguish each cluster. Each cluster will be visualized using word cloud with the purpose of looking for the most common venues available in each cluster.

Cluster 0

In [46]:
london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 0, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
Out [46]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
5 Clapton Pub Café Coffee Shop Park Cocktail Bar Turkish Restaurant Breakfast Spot Bar Bakery Gastropub
8 Hackney, Dalston Pub Coffee Shop Bakery Café Park Bookstore Pizza Place Wine Shop Brewery Grocery Store
19 Olympic Park Café Pub Park Art Gallery Italian Restaurant Coffee Shop Bistro Brewery Beer Bar Mediterranean Restaurant
27 East Finchley Café Pub Gym / Fitness Center Italian Restaurant Coffee Shop Forest Japanese Restaurant Indian Restaurant Bakery Hotel
29 Finsbury Park, Manor House Café Pub Turkish Restaurant Italian Restaurant Coffee Shop Tapas Restaurant Gym / Fitness Center Bakery Park Pizza Place
30 Highbury Pub Café Coffee Shop Park Bakery Pizza Place Ethiopian Restaurant Deli / Bodega Turkish Restaurant Soccer Stadium
32 Holloway Pub Café Coffee Shop Park Italian Restaurant Theater Wine Shop Ethiopian Restaurant Pizza Place Soccer Stadium
33 Hornsey, Crouch End Café Pub Turkish Restaurant Coffee Shop Bakery Japanese Restaurant Park Trail Pizza Place Grocery Store
40 Seven Sisters Turkish Restaurant Café Pub Park Coffee Shop Bakery Bar Gym Brewery Nightclub
41 Stoke Newington, Stamford Hill Café Pub Turkish Restaurant Breakfast Spot Coffee Shop Cocktail Bar Park Bakery Pizza Place Restaurant
48 Regents Park, Camden Town Café Coffee Shop French Restaurant Bar Grocery Store Pub Garden Music Venue Market Zoo Exhibit
50 Hampstead, Swiss Cottage Café Pub Park Bakery Gastropub Coffee Shop Bookstore Pizza Place Museum Deli / Bodega
53 West Hampstead, Kilburn, Queens Park Pub Café Bakery Pizza Place Coffee Shop Deli / Bodega Gym / Fitness Center Middle Eastern Restaurant Hostel Brazilian Restaurant
55 St Johns Wood Café Zoo Exhibit Coffee Shop Pub French Restaurant Garden Athletics & Sports Theater Bakery Sandwich Place
63 Camberwell Coffee Shop Café Pub Park Middle Eastern Restaurant Bar Italian Restaurant Pizza Place Brewery Cocktail Bar
69 Lambeth Café Pub Coffee Shop Park Hotel Theater Garden Italian Restaurant Cricket Ground Plaza
75 Walworth, Elephant & Castle Coffee Shop Pub Café Park Italian Restaurant Pizza Place Theater Art Gallery Hotel Gay Bar
80 East Dulwich Café Park Pub Pizza Place Coffee Shop Italian Restaurant Forest Mediterranean Restaurant Gym / Fitness Center Grocery Store
82 Herne Hill Coffee Shop Pub Café Cocktail Bar Pizza Place Park Market Brewery Vegetarian / Vegan Restaurant Restaurant
88 Brixton, Streatham Hill Coffee Shop Pub Market Brewery Cocktail Bar Restaurant Pizza Place Caribbean Restaurant Café Park
90 Clapham Pub Coffee Shop Italian Restaurant Restaurant Market Café Pizza Place Burger Joint Park Cocktail Bar
92 Fulham, Parsons Green Café Coffee Shop Park Pizza Place Pub Thai Restaurant Bakery Gastropub Tennis Court Fish & Chips Shop
94 South Lambeth, Nine Elms Café Coffee Shop Pub Park Bakery Gym / Fitness Center Restaurant Deli / Bodega Gastropub Supermarket
95 Stockwell, Brixton Coffee Shop Café Pub Cocktail Bar Park Pizza Place Market Caribbean Restaurant Gastropub BBQ Joint
97 Battersea, Clapham Junction Pub Coffee Shop Café Italian Restaurant Bakery Park Pizza Place Breakfast Spot Plaza Grocery Store
105 Wimbledon, Merton Pub Park Sushi Restaurant Tennis Court Tennis Stadium Thai Restaurant Café Bar Grocery Store Burger Joint
115 Maida Vale, Warwick Avenue Pub Bakery Pizza Place Café Restaurant Gym Gym / Fitness Center Bar Italian Restaurant Turkish Restaurant
116 Ladbroke Grove, North Kensington Pub Gym / Fitness Center Bakery Restaurant Pizza Place Café Bar Italian Restaurant Coffee Shop Persian Restaurant
117 Notting Hill, Holland Park Pub Bakery Pizza Place Gym / Fitness Center Italian Restaurant Restaurant Garden Coffee Shop Turkish Restaurant Gastropub
118 Shepherds Bush Pub Café Indian Restaurant Gastropub Coffee Shop Pizza Place Bakery Middle Eastern Restaurant Thai Restaurant Park
120 West Kensington Café Coffee Shop Pizza Place Pub Gastropub Bakery Italian Restaurant Park Middle Eastern Restaurant Cocktail Bar
In [47]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
df_cluster1 = london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 0, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
text = df_cluster1

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

Cluster 1

In [48]:
london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 1, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
Out [48]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
6 East Ham Grocery Store Supermarket Indian Restaurant Coffee Shop Fast Food Restaurant Hotel Discount Store Pub Furniture / Home Store Park
7 Forest Gate, Upton Park Grocery Store Pub Indian Restaurant Fast Food Restaurant Park Café Hotel Restaurant Coffee Shop Pharmacy
12 Manor Park Grocery Store Indian Restaurant Fast Food Restaurant Clothing Store Bakery Coffee Shop Pub Supermarket Park Hotel
13 Plaistow Grocery Store Pub Fast Food Restaurant Platform Coffee Shop Park Café Sandwich Place Supermarket Gym / Fitness Center
18 South Woodford Grocery Store Pub Coffee Shop Café Italian Restaurant Restaurant Metro Station Park English Restaurant Supermarket
28 Finchley Central Bakery Grocery Store Supermarket Gym / Fitness Center Pub Turkish Restaurant Italian Restaurant Café Japanese Restaurant Middle Eastern Restaurant
34 Lower Edmonton Turkish Restaurant Grocery Store Coffee Shop Fast Food Restaurant Pub Hotel Supermarket Bakery Train Station Gym / Fitness Center
36 Friern Barnet, New Southgate Grocery Store Pub Café Coffee Shop Park Pizza Place Greek Restaurant Dessert Shop Electronics Store Supermarket
37 North Finchley, Woodside Park Coffee Shop Café Supermarket Italian Restaurant Grocery Store Turkish Restaurant Pub Pharmacy Indian Restaurant Sandwich Place
38 Palmers Green Pub Grocery Store Coffee Shop Greek Restaurant Park Italian Restaurant Supermarket Pizza Place Café Bus Stop
39 Southgate Grocery Store Pub Café Park Gym / Fitness Center Italian Restaurant Coffee Shop Tennis Court Supermarket Bakery
45 Whetstone, Totteridge Coffee Shop Pub Grocery Store Café Supermarket Pharmacy Park Fish & Chips Shop Fast Food Restaurant Soccer Field
46 Winchmore Hill Park Pub Supermarket Grocery Store Pizza Place Clothing Store Coffee Shop Bakery Train Station Sports Club
47 Wood Green, Alexandra Palace Pub Café Grocery Store Park Coffee Shop Indian Restaurant Mediterranean Restaurant Greek Restaurant Turkish Restaurant Bakery
49 Cricklewood, Neasden Coffee Shop Café Grocery Store Park Pub Supermarket Hotel Fast Food Restaurant Bakery Italian Restaurant
51 Hendon, Brent Cross Grocery Store Coffee Shop Supermarket Café Gym / Fitness Center Pizza Place Pub Hotel Park Department Store
54 Mill Hill Italian Restaurant Grocery Store Pub Golf Course Platform Pizza Place Stationery Store Gym Pharmacy Bakery
56 Kinsbury, Colindale Supermarket Coffee Shop Grocery Store Café Gym / Fitness Center Pizza Place Park Pub Chinese Restaurant Asian Restaurant
57 Willesden, Harlesden, Kensal Green Café Coffee Shop Pizza Place Grocery Store Middle Eastern Restaurant Pub Fast Food Restaurant Bakery Train Station Thai Restaurant
58 Golders Green, Hampstead Gdn Suburb Grocery Store Coffee Shop Café Park Bakery Supermarket Hotel Korean Restaurant Sushi Restaurant Turkish Restaurant
64 Catford, Hither Green, Bellingham Grocery Store Supermarket Park Café Pub Italian Restaurant Coffee Shop Fast Food Restaurant Hardware Store Train Station
67 Eltham, Mottingham Grocery Store Fast Food Restaurant Park Pizza Place Pub Pharmacy Mediterranean Restaurant Convenience Store Gym Soccer Field
70 Lee, Grove Park Grocery Store Park Pub Café Italian Restaurant Supermarket Coffee Shop Soccer Field Platform Gym / Fitness Center
76 Woolwich, Plumstead Grocery Store Pub Supermarket Park Coffee Shop Clothing Store Bakery Gym / Fitness Center Café Hotel
83 South Norwood Grocery Store Pub Supermarket Platform Park Coffee Shop Train Station Café Tram Station Indian Restaurant
102 Streatham, Norbury Pub Grocery Store Café Supermarket Park Coffee Shop Pizza Place Pharmacy Breakfast Spot Bar
109 Acton Coffee Shop Grocery Store Pub Gym / Fitness Center Hotel Middle Eastern Restaurant Park Hookah Bar Bakery Gastropub
In [49]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
df_cluster2 = london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 1, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
text = df_cluster2

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

Cluster 2

In [50]:
london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 2, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
Out [50]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
3 Bow, Bromley-by-Bow Pub Café Coffee Shop Park Art Gallery Canal Lock Restaurant Turkish Restaurant Bar Wine Shop
4 Chingford, Highams Park Pub Coffee Shop Grocery Store Park Supermarket Sporting Goods Shop Turkish Restaurant Café Fast Food Restaurant Gym
9 Hackney, Homerton Pub Coffee Shop Café Bakery Pizza Place Park Bookstore Cocktail Bar Canal Lock Deli / Bodega
10 Leyton Pub Café Park Restaurant Coffee Shop Bar Indian Restaurant Italian Restaurant Juice Bar Grocery Store
11 Leytonstone Pub Café Park Grocery Store Mediterranean Restaurant Pizza Place Coffee Shop Bakery Restaurant Convenience Store
15 Stratford, West Ham Pub Café Park Grocery Store Art Gallery Coffee Shop Brewery Fish & Chips Shop Beer Bar Restaurant
17 Walthamstow Pub Grocery Store Coffee Shop Supermarket Café Brewery Pizza Place Gym / Fitness Center Restaurant Vegetarian / Vegan Restaurant
31 Highgate Pub Café Coffee Shop Italian Restaurant Park Bakery Gastropub Pizza Place Japanese Restaurant Mediterranean Restaurant
35 Muswell Hill Pub Café Coffee Shop Japanese Restaurant Indian Restaurant Grocery Store Deli / Bodega Park Forest Italian Restaurant
42 Tottenham Pub Coffee Shop Park Fast Food Restaurant Supermarket Turkish Restaurant Grocery Store Bar Pizza Place Train Station
43 Upper Edmonton Pub Coffee Shop Supermarket Turkish Restaurant Park Café Hotel Pizza Place Furniture / Home Store Fast Food Restaurant
44 Archway, Tufnell Park Pub Coffee Shop Café Pizza Place Bakery Italian Restaurant Gastropub Japanese Restaurant Trail Park
52 Kentish Town Pub Coffee Shop Café Gastropub Bakery Ice Cream Shop Pizza Place Italian Restaurant Mediterranean Restaurant Deli / Bodega
61 Blackheath, Westcombe Park Pub Park Grocery Store Coffee Shop Garden Bakery Supermarket Italian Restaurant Gym / Fitness Center Clothing Store
62 Brockley, Crofton Park, Honor Oak Park Pub Coffee Shop Café Park Bar Cocktail Bar Pizza Place Gastropub Italian Restaurant Fish & Chips Shop
65 Charlton Pub Park Coffee Shop Grocery Store Supermarket Gym / Fitness Center Clothing Store Bus Stop Hotel Furniture / Home Store
66 Deptford Pub Café Coffee Shop Bar Park Cocktail Bar Garden Bakery Grocery Store Market
68 Greenwich Pub Park Grocery Store Café Garden Bar Historic Site French Restaurant Supermarket Market
71 Lewisham, Hither Green Pub Café Park Gastropub Garden Gym / Fitness Center Restaurant Food Truck Coffee Shop Supermarket
72 New Cross, New Cross Gate Pub Coffee Shop Café Italian Restaurant Bar Pizza Place Brewery Gym / Fitness Center Gastropub Park
73 Peckham, Nunhead Pub Café Pizza Place Park Bar Coffee Shop Gastropub Indie Movie Theater Cocktail Bar Italian Restaurant
74 Rotherhithe, South Bermonsey, Surrey Docks Pub Park Brewery Coffee Shop Bar Beer Bar Food Truck Trail Café Street Food Gathering
77 Upper Norwood, Crystal Palace Pub Coffee Shop Park Italian Restaurant Café Train Station Grocery Store Gastropub Bakery Breakfast Spot
78 Penge, Anerley Pub Café Coffee Shop Supermarket Pizza Place Park Grocery Store Gastropub Italian Restaurant Gym / Fitness Center
79 Dulwich Pub Café Bakery Park Coffee Shop Grocery Store Farmers Market Brewery Gym / Fitness Center Italian Restaurant
81 Forest Hill Pub Coffee Shop Café Supermarket Park Grocery Store Gym / Fitness Center Indian Restaurant Pharmacy Fast Food Restaurant
84 Sydenham Pub Coffee Shop Café Pizza Place Supermarket Italian Restaurant Gym / Fitness Center Gastropub Park Train Station
85 West Norwood, Tulse Hill Pub Coffee Shop Grocery Store Café Bakery Park Italian Restaurant Brewery Gym / Fitness Center Supermarket
98 Balham Pub Coffee Shop Park French Restaurant Italian Restaurant Bakery Pizza Place Café Bar Burger Joint
99 Barnes, Castelnau Pub Park Café Coffee Shop Gastropub Farmers Market Restaurant Grocery Store Italian Restaurant Historic Site
100 Mortlake, East Sheen Pub Coffee Shop Grocery Store Café Park Pizza Place Farmers Market Gym French Restaurant Clothing Store
101 Putney, Roehampton Pub Coffee Shop Park Café Bar Italian Restaurant Indian Restaurant Portuguese Restaurant Gym / Fitness Center Sports Club
103 Tooting Pub Coffee Shop Café Italian Restaurant Indian Restaurant Bar Cocktail Bar Fish & Chips Shop Supermarket Park
104 Wandsworth, Earlsfield Pub Coffee Shop Café Bar Pizza Place French Restaurant Park Thai Restaurant Cocktail Bar Tennis Court
106 South Wimbledon, Raynes Park Pub Coffee Shop Grocery Store Park Sushi Restaurant Gym / Fitness Center Bar Bakery Burger Joint Café
110 Chiswick Coffee Shop Pub Park Café Grocery Store Bakery Gym / Fitness Center Gastropub Thai Restaurant French Restaurant
111 Ealing Coffee Shop Pub Park Italian Restaurant Pizza Place Café Burger Joint Grocery Store Gym / Fitness Center Persian Restaurant
112 Hammersmith Pub Coffee Shop Café Italian Restaurant Gastropub Park Pizza Place Middle Eastern Restaurant Grocery Store Turkish Restaurant
113 Hanwell Pub Park Hotel Supermarket Café Coffee Shop Persian Restaurant Brewery Gym Grocery Store
119 West Ealing Pub Park Coffee Shop Café Hotel Italian Restaurant Burger Joint Pizza Place Gym / Fitness Center Greek Restaurant
In [51]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
df_cluster3 = london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 2, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
text = df_cluster3

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

Cluster 3

In [52]:
london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 3, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
Out [52]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 Whitechapel, Stepney, Mile End Coffee Shop Café Restaurant Pub Cocktail Bar Hotel Farm Italian Restaurant Turkish Restaurant Pizza Place
1 Wapping Coffee Shop Hotel Pub Gym / Fitness Center Deli / Bodega French Restaurant Garden Tapas Restaurant Cocktail Bar Brewery
2 Bethnal Green, Shoreditch Coffee Shop Bakery Café Pub Bookstore Restaurant Pizza Place Market Italian Restaurant Flea Market
14 Poplar, Millwall, Isle of Dogs, Docklands Coffee Shop Pub Hotel Park Bar Italian Restaurant Plaza Burger Joint Gym / Fitness Center Indian Restaurant
16 Canning Town, North Woolwich, Docklands Hotel Coffee Shop Pub Grocery Store Park Chinese Restaurant Lounge Bar Scenic Lookout Asian Restaurant
20 Bloomsbury, Grays Inn Coffee Shop Bakery Hotel Theater Steakhouse Beer Bar Pizza Place Gym / Fitness Center Breakfast Spot Bookstore
21 Covent Garden, Holborn, Strand Hotel Theater Coffee Shop Plaza Bookstore Bakery Steakhouse Wine Bar History Museum Garden
22 Clerkenwell, Finsbury, Barbican Coffee Shop Hotel Cocktail Bar Gym / Fitness Center Pub Bar Café Beer Bar Falafel Restaurant Restaurant
23 Moorgate, Liverpool Street Coffee Shop Hotel Gym / Fitness Center Cocktail Bar Restaurant Italian Restaurant Vietnamese Restaurant Sushi Restaurant Café Bar
24 Monument, Tower Hill, Aldgate Coffee Shop Hotel Gym / Fitness Center Italian Restaurant Grocery Store Theater Scenic Lookout Bakery Market Cocktail Bar
25 Fleet Street, St. Pauls Hotel Theater Coffee Shop Gym / Fitness Center Scenic Lookout Beer Bar Art Gallery Art Museum Street Food Gathering Sushi Restaurant
26 Islington, Barnsbury, Canonbury Coffee Shop Pub Bakery Café Restaurant Italian Restaurant Organic Grocery Cocktail Bar Vietnamese Restaurant Sushi Restaurant
59 Waterloo, Bermondsey, Southwark, Borough Coffee Shop Hotel Pub Theater Grocery Store Scenic Lookout Street Food Gathering Deli / Bodega Burger Joint Cocktail Bar
87 Westminster, Belgravia, Pimlico Hotel Plaza Café Park Art Museum Boutique Mediterranean Restaurant Garden Gastropub Coffee Shop
89 Chelsea, Brompton Hotel Café Plaza Deli / Bodega Ice Cream Shop Coffee Shop Burger Joint Pub Bakery Gym / Fitness Center
91 Earls Court Italian Restaurant Hotel Coffee Shop Bakery Café Gym / Fitness Center French Restaurant Pizza Place Exhibit Science Museum
93 South Kensington Hotel Café Ice Cream Shop Italian Restaurant French Restaurant Coffee Shop Indian Restaurant Restaurant Mediterranean Restaurant Exhibit
96 West Brompton, Worlds End Bakery Hotel Coffee Shop Ice Cream Shop Italian Restaurant Gym / Fitness Center Café French Restaurant Garden Exhibit
107 Mayfair, Marylebone, Soho Hotel Juice Bar French Restaurant Coffee Shop Hotel Bar Burger Joint Bakery Movie Theater Art Gallery Clothing Store
108 Bayswater, Paddington Pub Hotel Café Restaurant Coffee Shop Garden Greek Restaurant Gym / Fitness Center Persian Restaurant Art Gallery
114 Kensington Hotel Garden Café Exhibit Indian Restaurant Coffee Shop Bakery Italian Restaurant Pub Restaurant
In [53]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
df_cluster4 = london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 3, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
text = df_cluster4

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

Cluster 4

In [54]:
london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 4, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
Out [54]:
District 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
60 Abbey Wood Supermarket Grocery Store Fast Food Restaurant Lake Train Station Trail Eastern European Restaurant Pharmacy Platform Warehouse Store
86 Thamesmead Supermarket Fast Food Restaurant Grocery Store Warehouse Store Furniture / Home Store Historic Site Food & Drink Shop Flea Market Soccer Field Mobile Phone Shop
In [55]:
# using the function set to remove any redundant stopwords
stopwords = set(STOPWORDS)

# passing the DataFrame to a new variable to extract the plain text content afterwards
df_cluster5 = london_merged_nonan.loc[london_merged_nonan['Cluster Labels'] == 4, london_merged_nonan.columns[[1] + list(range(5, london_merged_nonan.shape[1]))]]
text = df_cluster5

# generating the word cloud
wordcloud = WordCloud(
    width = 3000,
    height = 2000,
    random_state=1,
    background_color = 'Black',
    colormap='Pastel1',
    collocations=False,
    stopwords = STOPWORDS).generate(str(text))

# plotting the word cloud
plt.figure(figsize = (40,30))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis('off')
plt.show()

6. Results and Discussion

The explanatory analysis revealed that there is a wide variety of venue categories in London city ranging from restaurants, bars, pubs, bakeries to bookstores, art museums, hotels, gyms and so on. It is important to highlight the presence of high number of train stations, which implies that London has a great connectivity to airports and surrounding cities, saving time and increasing mobility for visitors who spent an average of 4.8 nights in 2019 in London, according to Statista. However, as stated in the Business Problem section, a good planning is needed due to the high variety of activities and places to visit.

The scraping and data cleaning processes gave a total of 121 Postal Codes, which implies a total of 32 boroughs, while the London city map showed an uniform distribution of all the districts over London territory. A random analysis containing the most relevant revenues, from the point of view of a visitor, revealed that hotels, restaurants, bars and theaters are the most common venues in London city overall considering all districts. More specifically, the most popular international restaurants are: Italian (with 280 restaurants), Indian (with 167 restaurants), Turkish (with 142 restaurants) and Japanese (with 86 restaurants) in descending order. The difference between the total number of restaurants and the number of restaurants by cuisine type is mainly due to how each label has been categorized in the raw data.

A more detailed analysis of these venues by district has been performed. The districts Canning Town, North Woolwich and Docklands (situated in east and southeast of London city) have the highest hotel availability with a total of 16 hotels, while the districts Earls Court (southwest), Finsbury Park and Manor House (north) resulted in the districts with the highest italian restaurants availability with a total of 6 each. Moreover, the districts East Ham (east-northeast), Forest Gate (east) and Upton Park (northeast) have the highest availability of indian restaurants with a total of 7 each.

A word cloud analysis of the most common venues of all districts has been developed. The most frequent words found were: Restaurant, Pub, Park, Coffee, Store, Shop, Italian, Hotel, Bakery, Grocery, Gym. This word cloud analysis validates the random analysis previously performed but also revealed other common venues that had not been analyzed yet such as pubs, parks, coffee shops, bakeries, groceries and gyms. A clustering analysis has been performed using k-means algorithm setting 5 clusters (cluster 0, cluster 1, cluster 2, cluster 3, cluster 4) using word cloud to get the most common venues in each cluster. Overall, the most common words found in all clusters were: restaurant, hotel, bar, coffee, pub, grocery, fitness, park, bakery and supermarket validating the previous analyses performed in this respect.

6.1. Limitations and recommendations for further research

There are a number of gaps in the present project that could be benefitted from further research. The explanatory analysis results depend on the accuracy of Foursquare data and the Milesfaster website has limitations as per the number of postal codes included. Furthermore, a more detailed evaluation should have included prices and iconic attractions in London city such as Buckingham Palace and Big Ben.

7. Conclusion

London is one of the most popular tourist destinations in Europe with full of things to do and visit. Leaving aside iconic attractions such as Buckingham Palace and Big Ben, this project explored a large number of districts aiming to find the most common venues and where are located geographically. From the visitors perspective, the most relevant venues found in the explanatory analysis were hotels, restaurants, bars, theaters, pubs, bakeries, groceries, coffee shops, gyms. The most popular cuisine types were italian food, followed by indian food, turkish food and japanese food. To sum up, most hotels were found in districts located in southwest and north of London city, while most restaurants were found in districts located in east and northeast of London city. By clustering all the districts with the purpose of creating major zones of interest (including a bigger number of potential locations) it was found that most of the venues revealed during the explanatory analysis are located in London center, center-east, south and north periphery too.

Although the decision of the optimal potential places to visit in London city will be taken by visitors, it can be concluded considering the results of the explanatory analysis that the most common and popular venues are located in the center, center-east and south periphery of London city. This recommendation is based on additional factors such as proximity of iconic attractions, availability of train stations and closeness to city center.